![](/img/trans.png)
[英]Unable to apply border-top and border-bottom to the <tr> tag
[英]How to: overflow text above border-top like with border-bottom when height: 0px
無論如何,當高度設置為height:0px;
時,我是否可以vertical-align
文本vertical-align
以顯示在border-top
就像我可以在border-bottom
height:0px;
?
HTML:
<ul id="experiment" style="background: #FFDD00;">
<li id="test1"><span class="v-align-bot">Chocolate</span></li>
<li id="test2"><span class="v-align-top">Potato</span></li>
</ul>
CSS:
#test1 {
height: 0px;
border-bottom: 50px solid #648291; /*grey*/
}
#test2 {
height: 0px;
border-top: 50px solid #FA8723; /*orange*/
}
.v-align-bot {
vertical-align: -50px;
}
.v-align-top {
vertical-align: 50px;
}
巧克力很容易在border-bottom
對齊。 馬鈴薯確實在li
上方對齊, 但 border-top
跟隨它。
TL; DR:無論如何,我能否使下面這個小提琴中的BUTTON
正確對准?
奇怪的是eh;)為此,實際上元素的邊框在元素外部渲染,因此沒有直接的方法,但是如果您要使文本在邊框上垂直居中,則需要更改夫婦標記以及CSS中的內容。
首先,使用簡單的span
標簽包裝單詞,而不是在CSS中使用以下規則
.v-align-bot span {
position: absolute;
top: 15px;
}
.v-align-top span {
position: absolute;
top: -35px;
}
還要確保您使用position: relative;
在下面的ID上,它們將在野外流出。
#test1 {
height: 0px;
border-bottom: 50px solid #648291; /*grey*/
position: relative;
}
#test2 {
height: 0px;
border-top: 50px solid #FA8723; /*orange*/
position: relative;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.