css3 - text-overflow為何會在li的子標簽a下失效
問題描述
<ul> <li><span>2014-05-28</span><a href='http://www.leifengta.com.cn/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. boot2docker無法啟動2. docker-compose中volumes的問題3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. nignx - docker內nginx 80端口被占用5. docker容器呢SSH為什么連不通呢?6. 關于docker下的nginx壓力測試7. docker安裝后出現Cannot connect to the Docker daemon.8. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值9. java - SSH框架中寫分頁時service層中不能注入分頁類10. dockerfile - 為什么docker容器啟動不了?

網公網安備