2015-08-18 28 views
1

我編程日曆,可以在這裏看到:溢出在表內的div中沒有​​被尊重?

http://8wayrun.com/calendar/month

我有一個width: 14%每個表格單元。這會在每列的大小相同的情況下產生一致性。我需要這14%保持完好。

我有一個問題,但我的溢出。如果您在該頁面上看,則可以看到我的活動爲7:00 PM - The Break Weekly,其中「每週」一詞被分解到第二行。我希望它做的是7:00 PM - The Break...。使用省略號溢出。

我曾嘗試以下的css:

.monthTable .monthMain .monthOccur 
{ 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
} 

然而,這不是爲我工作。當我使用該代碼時,white-space: nowrap受到尊重,但其餘的不是。它將表格單元的寬度擴大到14%以上。

有沒有辦法解決這個問題沒有設置固定的像素寬度?

回答

2

添加到.monthTable。這可以防止瀏覽器調整表格並且考慮您設置的寬度。

+0

你最好!它尊重帶有流體寬度的網站的框模型。 –

+0

@JasonAxelrod :) –

0

試試這個(加寬):

.monthTable .monthMain .monthOccur { 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 

    width: 119px; 

    border: 1px solid rgb(50, 50, 50); 
    -webkit-border-radius: 5px; 
    -moz-border-radius: 5px; 
    -khtml-border-radius: 5px; 
    border-radius: 5px; 
    padding: 5px; 
    font-size: 11px; 
} 

這裏是它現在看起來: result

+0

我問是否有辦法解決這個問題,但沒有添加固定的像素寬度。 –

+0

在這種情況下,如下所示:寬度:90%; –

1

設置一個寬度.monthTable .monthMain .monthOccur

.monthTable .monthMain .monthOccur { 
border: 1px solid rgb(50, 50, 50); 
-webkit-border-radius: 5px; 
-moz-border-radius: 5px; 
-khtml-border-radius: 5px; 
border-radius: 5px; 
padding: 5px; 
font-size: 11px; 
white-space: nowrap; 
overflow: hidden; 
text-overflow: ellipsis; 
width: 90%; 
margin: 0 auto; 
} 
+0

由於CSS盒模型的原因,這並不是真的有效。除非您的網站具有固定寬度,否則它不起作用。 –