[英]Pseudo-element cropped
I have no idea why my triangle pseudo-element gets cropped. 我不知道为什么三角形的伪元素会被裁剪。 I've been playing around the properties, but no result. 我一直在玩游戏,但没有结果。 It is supposed to be a classical triangle, where's my right angle?) Please, help! 它应该是一个经典的三角形,我的直角在哪里?)请帮忙! JSFiddle 的jsfiddle
<div id="slider">
<ul id="list">
<li>Eins</li>
<li>Zwei</li>
<li>Drei</li>
<li>Vier</li>
</ul>
</div>
#slider {
border: 1px solid #999;
position: relative;
width: 195px;
}
#slider:after {
content: " ";
border-bottom: 14px solid transparent;
border-left: 14px solid black;
border-top: 14px solid transparent;
height: 14px;
left: 190px;
position: absolute;
top: 20px;
width: 14px;
}
It doesn't get 'cut off'. 它不会被“切断”。 Your element has height which elongates the left hand border: 您的元素的高度会拉长左边框:
Your arrow is more 'stretched' vertically than it is 'cut off' horizontally. 您的箭头在垂直方向上比在水平方向上被“切断”更多。
Ensure your element has no height to it: 确保您的元素没有高度:
#slider { border: 1px solid #999; position: relative; width: 195px; } #slider:after { content: " "; border-bottom: 14px solid transparent; border-left: 14px solid black; border-top: 14px solid transparent; /* ----- */ height: 0; font-size: 0; /* ----- */ left: 190px; position: absolute; top: 20px; }
<div id="slider"> <ul id="list"> <li>Eins</li> <li>Zwei</li> <li>Drei</li> <li>Vier</li> </ul> </div>
Also note your 'width' style is redundant. 还要注意,您的“宽度”样式是多余的。 The triangle is created by the border and the content box itself is 'invisible'. 三角形是由边框创建的,内容框本身是“不可见的”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.