输入按钮悬停并与输入文本融合时出现问题

时间:2020-07-21 15:22:42

标签: html css input

我尽力融合了我从网络上获得的输入按钮图标...。并且还与我的标签...

如果仔细查看下面的图片,我页面上的按钮是图标和输入文字之间的橙色框。

加上它拒绝悬停

请,有人可以检查一下我在做什么,并提供一些帮助

<!DOCTYPE html>
<html>
<head>
    <title> TO DO LIST</title>
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />

    <link href="https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="Project.css">
</head>
<body>

<header>
    <h1>Ak's To Do List</h1>
</header>
<form>
    <input type="text" class="todo-input">
    <button class="todo-button" type="submit"></button>
    <i class="fas fa-plus-square"></i>
</form>

<div class="todo-container">
<ul class="todo-list">
    <div class="todo"></ul>
</div>

    <script type="text/javascript" src="Project.js"></script>
</body>
</html>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    background-image: linear-gradient(120deg, #f6d365, #fda085);
    color: white;
    font-family: "Indie Flower", sans-serif;
    min-height:100vh;
}

header{
    font-size: 1.5rem;
}

header,
form{
    min-height:20vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

form input, 
form button{
    padding: 0.5rem;
    font-size:1.5rem;
    border:none;
    background: white;
}

form button{
    color: #fda085;
    background: white;
    cursor: pointer;
    transition:  all 0.3s ease;
}

form button{
    background: #fda085;
    color: white;
}

My Todo page 我得到了什么

How it's supposed to be 应该如何

1 个答案:

答案 0 :(得分:1)

图标<i class="fas fa-plus-square"></i>可以放在按钮内:

<button class="todo-button" type="submit"><i class="fas fa-plus-square"></i></button>

这将为您提供所需的效果。

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    background-image: linear-gradient(120deg, #f6d365, #fda085);
    color: white;
    font-family: "Indie Flower", sans-serif;
    min-height:100vh;
}

header{
    font-size: 1.5rem;
}

header,
form{
    min-height:20vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

form input, 
form button{
    padding: 0.5rem;
    font-size:1.5rem;
    border:none;
    background: white;
}

form button{
    color: #fda085;
}

form button:hover {
  color: green;
}
<!DOCTYPE html>
<html>
<head>
    <title> TO DO LIST</title>
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />

    <link href="https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="Project.css">
</head>
<body>

<header>
    <h1>Ak's To Do List</h1>
</header>
<form>
    <input type="text" class="todo-input">
    <button class="todo-button" type="submit"><i class="fas fa-plus-square"></i></button>
</form>

<div class="todo-container">
<ul class="todo-list">
    <div class="todo"></ul>
</div>

    <script type="text/javascript" src="Project.js"></script>
</body>
</html>

要获得悬停效果,您需要使用:hover伪元素创建一个新的样式定义,如下所示。我将其包含在上面的代码段中。

form button:hover {
      color: green;
    }

有关:hover的更多信息,请参见此处:https://developer.mozilla.org/en-US/docs/Web/CSS/:hover

相关问题