[英]How to distribute elements evenly side by side?
I am trying to make team profiles for the website, what I want is it to 3 profiles to display horizontally evenly.我正在尝试为网站制作团队个人资料,我想要的是 3 个个人资料以水平均匀地显示。
<div>
<span>
<img>
<span></span>
</span>
<span>
<img>
<span></span>
</span>
<span>
<img>
<span></span>
</span>
</div>
right now output is:现在输出是:
<img><span><img><span><img><span>
output expected:预期输出:
<img> <img> <img>
<span> <span> <span>
You could use flex or grid.您可以使用 flex 或 grid。 Something like this:像这样的东西:
div {
display: flex;
justify-content: space-evenly;
}
div > span > * { //this is to move the spans below the imgs
display: block;
}
You can put every profile in an inline div and make span a block element, like您可以将每个配置文件放在一个内联 div 中并使 span 成为一个块元素,例如
img{width:70px;} span{display:block} .inline{display:inline-block;}
<div> <div class="inline"> <span> <img src="https://homepages.cae.wisc.edu/~ece533/images/airplane.png"> <span>User</span> </span> </div> <div class="inline"> <span> <img src="https://homepages.cae.wisc.edu/~ece533/images/airplane.png"> <span>User</span> </span> </div> <div class="inline"> <span> <img src="https://homepages.cae.wisc.edu/~ece533/images/airplane.png"> <span>User</span> </span> </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.