elh*_*ine 8 html css css3 flexbox
我正在尝试使用space-between
属性水平居中(img - .info - img).我面临一个小问题,space-between
不在元素之间添加空格.
我知道我错过了什么,但我无法理解!
HTML:
<ul>
<li class="box-match">
<a href="#">
<img src="http://lorempixel.com/20/21" class="team1" alt="">
<div class="info">
<span class="time">10:30</span>
<span class="score">0-2</span>
</div>
<img src="http://lorempixel.com/20/20" class="team2" alt="">
</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS:
a{
text-decoration: none;
width: 98px;
height: 40px;
display: flex;
flex-flow: row no-wrap;
align-items: center;
align-content: space-between;
background-color: lightgray;
}
.info{
text-align: center;
display: block;
width: 40px;
}
ul{
list-style: none;
}
Run Code Online (Sandbox Code Playgroud)
Jos*_*ier 14
你在找justify-content: space-between
.
CSS
justify-content
属性定义当在当前行的主轴中对齐flex项时,浏览器如何在元素之间和周围分配可用空间.在应用长度和自动边距之后完成对齐,这意味着,如果存在至少一个flex-grow
不同于0的柔性元素,则它将没有效果,因为没有任何可用空间.
a {
text-decoration: none;
width: 98px;
height: 40px;
display: flex;
flex-flow: row no-wrap;
align-items: center;
justify-content: space-between;
background-color: lightgray;
}
Run Code Online (Sandbox Code Playgroud)