gpt4 book ai didi

html - 使用伪元素时如何 overflow hidden 文本(:before & :after)?

转载 作者:太空宇宙 更新时间:2023-11-04 00:00:48 25 4
gpt4 key购买 nike

我正在为位于内容 div 上的倾斜选项卡设计一种高级样式。

我刚刚解决了这个问题,按照创建建议遵循 :before 和 :after 来塑造 div。但是,我一直试图让 div 本身使用最大宽度而不是宽度:

HTML

<br>
<div class="tab">Really really really really really really long content title</div>
<div class="tab-content">Content text</div>

CSS

.

tab-content, .tab, .tab:before, .tab:after {
background-color: #f5f5f5;
}
body {
background-color: #666;
}
.tab-content {
border-left: 1px solid blue;
border-right: 1px solid blue;
border-bottom: 1px solid blue;
border-top: 1px solid blue;
margin-top: -1px;
padding-top:10px;
padding-bottom:20px;
padding-left:10px;
padding-right:10px;
}
.tab:before {
}
.tab {
max-width: 150px;
display:block;
border-left: 1px solid blue;
border-top: 1px solid blue;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
height: 50px;
border-radius: 15px 100px 0px 0px;
position: relative;
z-index: 100000000;
line-height:50px;
padding-left:20px;
}
.tab:after {
border-right: 1px solid blue;
border-top: 1px solid blue;
border-top-left-radius: 0px;
border-top-right-radius: 10px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 00px;
display: block;
content:" ";
width: 150px;
height: 50px;
top: -1px;
position: absolute;
right: -28px;
transform:skewX(45deg);
-ms-transform:skewX(45deg);
-webkit-transform:skewX(45deg);
z-index: -1;
}

有什么想法吗?

jsFiddle 在这里:http://jsfiddle.net/robmc/ZvEyx/9/

最佳答案

如果你对语义不太讲究,你可以试试:

<div class="tab"><div>Really really really really really...</div></div>

并添加以下 CSS 规则:

.tab div {
outline: 1px dotted blue; /* for demo only... */
overflow: hidden;
height: inherit;
}

child <div>可以用 header 代替,这可能有助于 SEO。

fiddle :http://jsfiddle.net/audetwebdesign/dyCXT/

关于html - 使用伪元素时如何 overflow hidden 文本(:before & :after)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16826048/

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