HTML   发布时间:2022-04-14  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html – 文本背景颜色的溢出大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我将背景颜色应用于我的国家/地区列表中的链接.它一般运作良好:

但是,对于名字较长的国家来说,效果并不好.

我试图让黄色溢出所有东西并清楚地显示国家的全名.

HTML

<div class="flagList">
<div class="flagcolumn"> ... </div>
<div class="flagcolumn"> ... </div>
<div class="flagcolumn"> ... </div>
...
</div>@H_607_9@ 
 

CSS:

.flagcolumn {
    width: 33%;
    float: left;
    border:0px solid;
    height:1.6em;
    overflow:hidden;
    white-space:nowrap; 
    text-overflow:ellipsis;
    z-index: 1; position:relative;
}

.flagcolumn:hover {
   overflow:visible;
   z-index: 2; position:relative;
   display: inline;
   BACkground-color:yellow;
}@H_607_9@

解决方法

你可以通过将.flagcolumn的内容包装在一个额外的元素中,将其设置为显示:inline-block;而是设置背景:
.flagcolumn {
    float: left;
    height: 1.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 33%;
    z-index: 1;
}
.flagcolumn:hover {
    overflow: visible;
    position: relative;
    z-index: 2;
}
.flagcolumn:hover span {
    BACkground-color: yellow;
    display: inline-block;
    height: 100%;
}@H_607_9@ 
 
<div class="flagList">
    <div class="flagcolumn"><span>This is test text!</span></div>
    <div class="flagcolumn"><span>This is a lot longer test text! This is a lot longer test text!</span></div>
    <div class="flagcolumn"><span>This is a lot longer test text! This is a lot longer test text!</span></div>
</div>@H_607_9@ 
 

JS小提琴:http://jsfiddle.net/hL9qfuvb/1/

大佬总结

以上是大佬教程为你收集整理的html – 文本背景颜色的溢出全部内容,希望文章能够帮你解决html – 文本背景颜色的溢出所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。