我div
在我的网页上设置了以下 HTML 和 CSS。
<style type="text/css">
.div-set {
margin: 5px 2px;
}
.div-set > .widget:nth-child(3n-1) {
margin: 20px 32px;
}
.widget {
width: 300px;
height: 300px;
border: 2px solid #dbdbdb;
padding: 0px;
position: relative;
display:inline-block;
}
.widget h2 {
color: white;
text-align: center;
margin: 0;
padding: 2px 5px;
font-weight: bold;
margin: 2px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
.widget p {
padding: 3px 10px;
padding-bottom: 15px;
}
.widget > a {
position:absolute;
bottom:0px;
right:0px;
text-decoration:none;
background:#dbdbdb;
color:black;
padding:2px;
border-bottom-right-radius:5px;
}
</style>
<div class="div-set">
<div class="widget">
<h2>Founder</h2>
<p>
<b>Late Shri Brahmdutta Sharma</b> has founded this
Goshala in 1999 with providing shelter to only three cows and number of cows becomes thirty in just first two months.
</p>
<a href="#">Learn more</a>
</div>
<div class="widget">
<h2>Founder</h2>
<p>
<b>Late Shri Brahmdutta Sharma</b> has founded this
Goshala in 1999 with providing shelter to only three cows and number of cows becomes thirty in just first two months.
</p>
<a href="#">Learn more</a>
</div>
<div class="widget">
<h2>Founder</h2>
<p>
<b>Late Shri Brahmdutta Sharma</b> has founded this
Goshala in 1999 with providing shelter to only three cows and number of cows becomes thirty in just first two months.
</p>
<a href="#">Learn more</a>
</div>
<div class="widget">
<h2>Founder</h2>
<p>
<b>Late Shri Brahmdutta Sharma</b> has founded this
Goshala in 1999 with providing shelter to only three cows and number of cows becomes thirty in just first two months.
</p>
<a href="#">Learn more</a>
</div>
<div class="widget">
<h2>Founder</h2>
<p>
<b>Late Shri Brahmdutta Sharma</b> has founded this
Goshala in 1999 with providing shelter to only three cows and number of cows becomes thirty in just first two months.
</p>
<a href="#">Learn more</a>
</div>
<div class="widget">
<h2>Founder</h2>
<p>
<img runat="server" src="~/CSS/slide/btns-next-prev.png" style="height:50px; width:100px;" alt="Alternate Text" />
<b>Late Shri Brahmdutta Sharma</b> has founded this
Goshala in 1999 with providing shelter to only three cows and number of cows becomes thirty in just first two months.
</p>
<a href="#">Learn more</a>
</div>
</div>
我img
在最后一个 div 中使用标签添加了一个图像,但正如您在网页上看到的那样,它的所有相邻 div 都略微移动到底部,如下图所示:
display
将属性更改为inline-table
在 Firefox 中工作,但不能在 chrome 中工作。我试过删除float
图像中删除属性,但没有运气。
是什么导致了这种意外行为..??我该如何解决..?
请注意:如果我在一行中的所有三个div (.widget)
中添加图像(一行有三个 div),则不会发现此类问题。我div
在一行中添加两个图像,而不是剩下的一个会稍微移到底部。