2014-10-28 55 views
0

我有一些標籤內容。它的一切都很精美,除非我需要它在頁面高度超過頁面所包含的頁面時「向下」推送頁面。如何獲取標籤內容以「推」其他頁面內容而不是覆蓋?

當你點擊標籤3時,你可以看到問題here。 有沒有我需要改變我的網站的其他佈局的這種簡單的修復? 我可以通過將
語句添加到選項卡式內容所在的頁面使其工作,但這實際上不是一個可行的解決方案。

這是顯示選項卡式內容的html。請注意「br」語句,因此選項卡1和選項卡2的內容不會與我的頁面的其餘部分重疊。

<ul class="tabs"> 
      <li> 
       <input type="radio" checked name="tabs" id="tab1"> 
       <label for="tab1">tab 1</label> 
       <div id="tab-content1" class="tab-content animated fadeIn"> 
       This is ok 
       </div> 
      </li> 
      <li> 
       <input type="radio" name="tabs" id="tab2"> 
       <label for="tab2">tab 2</label> 
       <div id="tab-content2" class="tab-content animated fadeIn"> 
        This is ok too. 
       </div> 
      </li> 
      <li> 
       <input type="radio" name="tabs" id="tab3"> 
       <label for="tab3">tab 3</label> 
       <div id="tab-content3" class="tab-content animated fadeIn"> 
       "This isn't ok :(But I must explain to you how all this mistaken idea of  denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" 
       </div> 
      </li> 
     </ul> 


<br> 
<br> 
<br> 
<br> 
<br> 
<br> 

這裏是CSS:

.tabs input[type=radio] { 
    position: absolute; 
    top: -9999px; 
    left: -9999px; 
} 
.tabs { 
    width: 650px; 
    float: none; 
    list-style: none; 
    position: relative; 
    padding: 0; 
    margin: 75px auto; 
    background-color: grey; 
} 
.tabs li{ 
    float: left; 
} 
.tabs label { 
    display: block; 
    padding: 10px 20px; 
    border-radius: 2px 2px 0 0; 
    color: #08C; 
    font-size: 24px; 
    font-weight: normal; 
    font-family: 'Roboto', helveti; 
    background: grey; 
    cursor: pointer; 
    position: relative; 
    top: 3px; 
    -webkit-transition: all 0.2s ease-in-out; 
    -moz-transition: all 0.2s ease-in-out; 
    -o-transition: all 0.2s ease-in-out; 
    transition: all 0.2s ease-in-out; 
} 
.tabs label:hover { 
    background: rgba(255,255,255,0.5); 
    top: 0; 
} 

[id^=tab]:checked + label { 
    background: #08C; 
    color: white; 
    top: 0; 
} 

[id^=tab]:checked ~ [id^=tab-content] { 
    display: block; 
} 
.tab-content{ 
/* z-index: 2;*/ 
    display: none; 
    text-align: left; 
    width: 100%; 
    font-size: 20px; 
    line-height: 140%; 
    padding-top: 10px; 
    background: #08C; 
    padding: 15px; 
    color: black; 
    position: absolute; 
    top: 53px; 
    left: 0; 
    box-sizing: border-box; 
    -webkit-animation-duration: 0.5s; 
    -o-animation-duration: 0.5s; 
    -moz-animation-duration: 0.5s; 
    animation-duration: 0.5s; 
} 

回答

0

您可以設置overflow:hidden.tabs

實施例:

.tabs { 
    width: 650px; 
    float: none; 
    list-style: none; 
    position: relative; 
    padding: 0; 
    margin: 75px auto; 
    background-color: grey; 
    overflow:hidden; 
} 
+0

我要去給一個向右走,現在...... 無賴,沒有工作。只顯示標籤和內容消失。 – arkyc 2014-10-28 12:32:04

0

高度需要PX是一個有效的規則。但是,你不想在這樣的東西上硬編碼高度。

#tab_container { 
    background: red; 
    overflow: auto; 
    height: 500; 
}