![](/img/trans.png)
[英]Unable to apply border-top and border-bottom to the <tr> tag
[英]Border-top not inline, border-bottom inline
我有一個簡單的圖像,我想給它上邊框和下邊框。 這是我的代碼:
<div class="details-big">
<img src="../images/full/full21.jpg" alt="title" />
</div>
CSS:
.details-big {
border-top: 8px solid #f0f0f0;
border-bottom: 8px solid #f0f0f0;
}
問題在於,邊框頂部會截去圖像的一部分,而邊框底部會截取相反的部分,甚至在顯示邊框底部之前都會添加白色填充。
我只是希望將邊框整齊地添加到邊框,而不會切除圖像的任何空格或部分。 CSS有可能嗎?
實際上,它並沒有在頂部被切斷,它在底部只有一個空間,由內聯img
呈現。 如果div僅包含圖像,則可以為div設置font-size:0
。 您也可以為img
設置邊框:
.details-big {
border-top: 8px solid #f0f0f0;
border-bottom: 8px solid #f0f0f0;
font-size:0;
}
您也可以為img
設置display:block
:
.details-big > img {
display:block;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.