css3 - text-overflow為何會在li的子標簽a下失效
問題描述
<ul> <li><span>2014-05-28</span><a href='http://www.aoyou183.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. python - beautifulsoup獲取網頁內容的問題2. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題3. docker鏡像push報錯4. docker - 如何修改運行中容器的配置5. docker-machine添加一個已有的docker主機問題6. fragment - android webView 返回后怎么禁止重新渲染?7. dockerfile - [docker build image失敗- npm install]8. angular.js - 在終端中用yeoman啟用angular-generator報錯,求解?9. Android "1"=="1" 到底是true還是false10. android studio總是在processes running好久
