gpt4 book ai didi

html - 使用 css 设置文本溢出可见的背景颜色

转载 作者:太空宇宙 更新时间:2023-11-03 23:29:44 26 4
gpt4 key购买 nike

我设置了我的 <P>带有固定高度和 overflow:hidden 的标签.在它的悬停效果上,我设置了 overflow:visible;

我的问题是文本显示但我想设置 z-index<p> 的背景颜色, 背景显示仅适用于 max-width<P> .我想在它覆盖的文本高度处更改背景颜色。

CSS:

.oe_description {   
overflow:hidden;
max-height:4.2em;
text-overflow: ellipsis;
}
.oe_description:hover {
overflow:visible;
position:relative;
z-index:100;
background: #e5f2f7;
font-weight:bold;
}

参见:FIDDLE

最佳答案

JSFiddle - DEMO

您可以使用 max-height: none;.oe_description:hover

CSS:

.oe_description {   
overflow:hidden;
/* 4 times the line-height to show 4 lines */
/*max-height: 5.6em;*/
/* 3 times the line-height to show 3 lines */
max-height:4.2em;
text-overflow: ellipsis;
}
.oe_description:hover {
overflow:visible;
position:relative;
z-index:100;
background: #e5f2f7;
font-weight:bold;
max-height: none;
}

HTML:

<div class="col-xs-10 non_padding">
<p class="oe_description">
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
When text must stay on one line, but there is not enough room for it all, this article provides a solution.
</p>
</div>

关于html - 使用 css 设置文本溢出可见的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25718708/

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