css3 - text-overflow为何会在li的子标签a下失效
问题描述
<ul> <li><span>2014-05-28</span><a href='https://www.haobala.com/wenda/news.html'>这不是广告这不是广告这不是广告这不是广告这不是广告这不是广告这不是广告这不是广告这不是广告这不是广告这不是广告</a></li></ul>
设置的CSS如下
li{ overflow: hidden; white-space: nowrap; text-overflow:ellipsis; width: 747px;}
为什么给a设置同样的样式会失效,而li不会
问题解答
回答1:设置 a { display: inline-block; } 即可。
Text overflow can only happen on block or inline-block level elements, because the element needs to have a width in order to be overflow-ed. The overflow happens in the direction as determined by the direction property or related attributes. - via: https://css-tricks.com/almanac/properties/t/text-overflow/
回答2:在给a设置的时候,加上display: inline-block;
相关文章:
1. 问题Unknown column ’’ in ’where clause’2. angular.js - 如何控制ngrepeat输出的个数3. html - vue项目中用到了elementUI问题4. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?5. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决6. javascript - vue组件通过eventBus通信时,报错a.$on is not a function7. css3 - css怎么实现图片环绕的效果8. linux - ubuntu 命令行中文 显示菱形,期望通过引入字体解决而不是zhcon这种方式9. ionic 项目 ionic build android -release 打包时报错10. python - 如何用pandas处理分钟数据变成小时线?

网公网安备