gpt4 book ai didi

html - 如何固定这个网格的高度?

转载 作者:行者123 更新时间:2023-11-28 06:02:30 24 4
gpt4 key购买 nike

enter image description here我创建了一个四列内容网格,其中包含图像和文本。我面临的问题是网格框的高度不相等。当有短文本时,框会根据文本长度花费。这是我的代码,以便更好地理解

HTML:

<ul class="rig">
<li>
<a href="#">
<h2><strong>This text 1</strong></h2>
<img src="css/images/image.jpg" />
</a>
</li>
<li>
<a href="#">
<h2><strong>This text 2</strong></h2>
<img src="css/images/image1.jpg" />
</a>
</li>
<li>
<a href="#">
<h2><strong>This text 3</strong></h2>
<img src="css/images/image2.jpg" />
</a>
</li>
<li>
<a href="#">
<h2><strong>This text 4</strong></h2>
<img src="css/images/image3.jpg" />
</a>
</li> </ul>

CSS:

ul.rig {
list-style: none;
font-size: 0px;
margin-left: -4.3%;
margin-bottom: 20px;
}
ul.rig li {
width: 170px;
display: inline-block;
margin-top: 10px;
margin-left: 10px;
margin-right: 5px;
margin-bottom: 5px;
padding: 2px 3px 5px;
background: #F1f1f1 url() repeat-x top;
border: 1px solid #c9c9c9;
font-size: 16px;
font-size: 1rem;
vertical-align: top;
box-shadow: 0 0 5px #ddd;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
margin-left: 5px;
overflow: hidden;
}
ul.rig li a {
text-decoration: none;
}
ul.rig li img {
width: 145px;
height: 180px;
margin: 5px 7px 14px;
border: 2px solid #535355;
padding: 0px 0px;
transition: all 400ms ease-in-out;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
-o-transition: all 400ms ease-in-out;
-ms-transition: all 400ms ease-in-out;
}
ul.rig li img:hover {
opacity: 0.7;
}
ul.rig li h2 {
color: #222;
font-weight: bold;
font: 14px Oswald;
line-height: 12px;
text-shadow: 2px 3px 4px #fff;
margin-bottom: 0px;
margin-top: 4px;
padding: 2px;
text-align: center;
}
ul.rig li h2:hover {
color: #0470d9;
}

i have added an image of what is happening and what i want to accomplishplease have look at the second image,i think this will make it clear what i want to acomplish

最佳答案

目前有两种解决方案:1) 为长段落添加阅读更多2)设置最小高度(最大段落的高度,所以每个框都一样)

关于html - 如何固定这个网格的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36671827/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com