[英]Equal elements' height in rows using w3.css
I've been trying to make my rows' elements' height be equal but still haven't succeeded. 我一直在尝试使行元素的高度相等,但是仍然没有成功。 Do you have any ideas how to do that?
你有什么想法怎么做?
Thanks, cheers. 谢谢,加油。
<div class="w3-row">
<div class="w3-container w3-quarter w3-green text-center matrix-element">
<h3><i class="material-icons">person</i> name</h3>
<p>100112</p>
</div>
<div class="w3-container w3-quarter w3-green text-center matrix-element">
<h3><i class="material-icons">person</i> name</h3>
<p>100112</p>
</div>
<div class="w3-container w3-quarter w3-green text-center matrix-element">
<h3><i class="material-icons">person</i> name</h3>
<p>100112</p>
</div>
<div class="w3-container w3-quarter w3-green text-center matrix-element">
<h3><i class="material-icons w3-xxlarge">remove_circle_outline</i></h3>
</div>
</div>
flexbox
can do that flexbox
可以做到
.w3-row {
display: flex;
}
.w3-container {
flex:1;
}
The trick is to remove the CSS class w3-xxlarge
from the <i>
-tag containing the circular glyph, because the line-height of that glyph using that class differs from the default line-height for the glyps or text in the other divs. 技巧是从包含圆形字形的
<i>
-tag中删除CSS类w3-xxlarge
,因为使用该类的该字形的行高与其他div中的字形或文本的默认行高不同。 。
I have also added min-height: 20px;
我还添加了
min-height: 20px;
for the p
-tags to compensate for no content. p
标签不补偿任何内容。
I have had this same problem recently, and flexbox styling can work unless you need your site to be suitable for a wider range of browsers eg. 我最近也遇到过同样的问题,除非您需要自己的网站适合更广泛的浏览器,否则flexbox样式可以工作。 IE9 and below ref: http://caniuse.com/#search=flexbox
IE9及以下版本: http : //caniuse.com/#search=flexbox
I use a negative margin technique which would mean doing this: 我使用负边距技术,这意味着要这样做:
.w3-quarter {
padding-bottom: 100px;
margin-bottom: -100px;
}
Works on bootstrap grid rows as well! 也适用于引导网格行!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.