2015-10-26 65 views
2

這是一些Safari bug嗎?文本溢出在Safari中居中顯示的文本很奇怪

<div style="white-space:nowrap;text-overflow:ellipsis;overflow:hidden;padding:0 250px;text-align:center"> 
Skin-to-Skin Direct Look Cadaveric Training Program 
</div> 

文本對齊:中心

enter image description here

沒有文字對齊:中心

enter image description here

回答

0

它修復了問題,我

<div style="padding:0 250px;"> 
    <div style="white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:center"> 
    Skin-to-Skin Direct Look Cadaveric Training Program 
    </div> 
</div> 
0

這是由於填充。如果你刪除它,那麼它應該工作。

HTML

<link rel="stylesheet" href="style.css" /> 

<div class="mydiv"> 
Skin-to-Skin Direct Look Cadaveric Training Program 
</div> 

CSS

.mydiv { 
    white-space: nowrap; 
    text-overflow: ellipsis; 
    overflow: hidden; 
    /* padding: 0 250px;*/ 
    text-align:center; 
    background-color: green;  
} 

尖叫:enter image description here

寬:enter image description here

+0

不,不是。在你的屏幕上,容器的寬度和文字都會更寬這種情況是當容器寬度小於文本時。 – Ilya

+0

試試這個CSS: .mydiv { \t display:block; \t溢出:auto; \t text-overflow:ellipsis; \t溢出:隱藏; \t text-align:center; \t background-color:green; \t } – l3aronsansgland

相關問題