2014-10-28 20 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; 
}