【发布时间】:2020-11-04 09:28:31
【问题描述】:
我在尝试拉伸我的 li 元素以适应容器的宽度时遇到了很多问题。我尝试弄乱每个 li 的宽度并弄乱其他 Flexbox 实用程序以尝试使其正常工作,但无济于事。 那么,我怎样才能改变每个 li 的宽度以适应容器的宽度,就像与 待办事项列表 标题和文本框?
这是网页的图片: https://i.stack.imgur.com/7WgR9.png
然后这是我的 HTML 和 CSS:
body {
font-family: Roboto;
background: -webkit-linear-gradient(90deg, #2BC0E4 10%, #EAECC6 90%); /* Chrome 10+, Saf5.1+ */
background: -moz-linear-gradient(90deg, #2BC0E4 10%, #EAECC6 90%); /* FF3.6+ */
background: -ms-linear-gradient(90deg, #2BC0E4 10%, #EAECC6 90%); /* IE10 */
background: -o-linear-gradient(90deg, #2BC0E4 10%, #EAECC6 90%); /* Opera 11.10+ */
background: linear-gradient(90deg, #2BC0E4 10%, #EAECC6 90%); /* W3C */
}
.heading {
background-color: #2980b9;
color: white;
}
.container {
margin-top: 100px;
width: 400px;
padding: 0;
}
ul {
list-style-type: none;
}
.item {
background-color: #fff;
width: 100%;
}
.item:nth-child(2n) {
background-color: #f7f7f7;
}
.header {
font-size: 24px;
font-weight: normal;
}
input {
width: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="container">
<div class="row d-flex justify-content-between align-items-center heading">
<h1 class="ml-4 header">TO-DO LIST</h1>
<h4><i class="fa fa-plus mr-2 mt-2" aria-hidden="true"></i></h4>
</div>
<div class="row d-flex">
<input class= "pb-5"type="text" placeholder="Add New Todo">
</div>
<div>
<ul class="row d-flex no-gutter">
<div class="d-flex row item"><li><span>X</span> Row 1</li></div>
<div class="d-flex row item"><li><span>X</span> Row 2</li></div>
<div class="d-flex row item"><li><span>X</span> Row 3</li></div>
</ul>
</div>
</div>
</body>
【问题讨论】:
标签: javascript html css bootstrap-4 flexbox