This question already has answers here:
CSS text-overflow: ellipsis; not working?
                                
                                    (14个回答)
                                
                        
                                2年前关闭。
            
                    
我试过使用text-overflow:省略号;这种语法,但不起作用,有人可以帮助我吗

HTML

   <div class="product-desc">
         <p>How to show dots if text is exceeds than the limit</p>
    </div>


我用过的风格

.product-desc{
    padding: 0.8em 1.5em;
    background: #337AB7;
    text-align: center;
     text-overflow: ellipsis;
}
.product-desc p{
    font-size: 1.2em;
    color: #fff;
    margin-bottom: 0.5em;
    font-family: 'Carrois Gothic', sans-serif;
}

最佳答案

请尝试以下方法:

.product-desc p{
    font-size: 1.2em;
    color: #fff;
    margin-bottom: 0.5em;
    font-family: 'Carrois Gothic', sans-serif;
    width:180px;
    white-space: nowrap;
    overflow:hidden !important;
    text-overflow: ellipsis;
}

关于html - 如果内容超出html格式,如何显示点(…),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44106533/

10-12 13:00
查看更多