Javascript CSS-图标的垂直对齐未正确显示
我一直在尝试将垃圾箱显示在右侧,但它们似乎放置得不太好,我是CSS新手,我浏览过互联网,但没有运气,或者我没有意识到这一点。 垃圾箱似乎与背景不成比例,因此如果我想让它填满标签,它会从箱子中溢出Javascript CSS-图标的垂直对齐未正确显示,javascript,html,css,Javascript,Html,Css,我一直在尝试将垃圾箱显示在右侧,但它们似乎放置得不太好,我是CSS新手,我浏览过互联网,但没有运气,或者我没有意识到这一点。 垃圾箱似乎与背景不成比例,因此如果我想让它填满标签,它会从箱子中溢出 #container { box-shadow: 0 0 3px rgba(0, 0, 0, 0.2); width: 360px; background-color: #f7f7f7; margin: 100px auto; } .completed { co
#container {
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
width: 360px;
background-color: #f7f7f7;
margin: 100px auto;
}
.completed {
color: gray;
text-decoration: line-through;
}
body {
font-family: Roboto;
background: #FFAFBD;
background: -webkit-linear-gradient(to right, #ffc3a0, #FFAFBD);
background: linear-gradient(to right, #ffc3a0, #FFAFBD);
}
li {
background-color: white;
height: 40px;
line-height: 40px;
color: #666;
}
input {
font-size: 18px;
background-color: #f7f7f7;
width: 100%;
padding: 13px 13px 13px 20px ;
box-sizing: border-box;
color: #2980b9;
}
input:focus{
background-color: white;
border: 3px solid #2980b9;
outline: none;
}
li:nth-child(2n){
background-color: #f7f7f7;
}
span {
height: 35px;
width: 40px;
display: inline-block;
margin-right: 20px;
margin: 0 auto;
text-align: center;
color: white;
background-color: #e74c3c;
}
h1 {
background-color: #2980b9;
color: white;
margin: 0;
padding: 10px 20px;
text-transform: uppercase;
font-size: 24px;
font-weight: normal;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
#plus {
width: 20px;
height: 20px;
float: right;
margin-top: 3px;
}
.remove {
height: 20px;
width: 15px;
}
提前谢谢你的帮助。
使用Flexbox!给你的和给a显示器:flex;通过这种方式,您可以控制其子对象的位置(在本例中为您的子对象)
李{
显示器:flex;
}
跨度{
显示器:flex;
证明内容:中心;
对齐项目:居中;
边距:02px0;
}
这是一张工作票。
这里有一个很好的指南。让你跨越的元素与li的高度相同,这样红色背景就完全填满了,怎么样 跨度{ 高度:40px; }
就像这样?我建议您使用字体很棒的图标,而不是图像。那为什么会起作用呢?谢谢,顺便说一句,这样更容易控制。它被当作文本处理。谢谢!这有帮助
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/CSS/todo.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="">
<title>Trello</title>
</head>
<body>
<div id="container">
<h1>To-do List <img id="plus" src="assets/Plus.png" alt=""></h1>
<input type="text" placeholder="Add New Todo...">
<ul>
<li><span><img class="remove" src="assets/Bin.png" alt=""></span> Go to potions class</li>
<li><span><img class="remove" src="assets/Bin.png" alt=""></span> Buy New Robes</li>
<li><span><img class="remove" src="assets/Bin.png" alt=""></span> Visit Hagrid</li>
</ul>
</div>
<script src="assets/JS/lib/Jquery.js"></script>
<script src="assets/JS/Custom/todos.js"></script>
</body>
</html>