简体   繁体   English

Internet Explorer CSS显示块问题

[英]Internet Explorer CSS display block issue

I'm trying to create a simple tab menu using a table and div blocks. 我正在尝试使用表格和div块创建一个简单的选项卡菜单。 When a tab is clicked, the style of the tab changes to create the effect that the tabs were switched and the body, which is a div block inside a table cell, is switched for another div block using css (display:block and display:none). 单击选项卡时,选项卡的样式会更改,以产生以下效果:切换选项卡,并使用CSS将主体(表单元格内的div块)切换为另一个div块(display:block和display:没有)。 It works the way it's supposed to in firefox, but in IE 11 the tabs size are modified when they are switched. 它按照预期在firefox中的方式工作,但是在IE 11中,切换选项卡时会修改它们的大小。

Here is the page: Tab Example 这是页面: 选项卡示例

 function tabClick(tab, bodyId) { // tabs and bodyes arrays var tabCol = [document.getElementById('tab1'), document.getElementById('tab2'), document.getElementById('tab3')]; var bodyCol = [document.getElementById('body1'), document.getElementById('body2'), document.getElementById('body3')]; for (var i = 0; i < tabCol.length; i++) { // find the tab that was clicke and // set it's status to selected. set // the others to unselected if (tab === tabCol[i]) { tabCol[i].className = 'tabSel'; } else { tabCol[i].className = 'tabUnsel'; } // show the body related to the selected // tab and hide the others if (bodyCol[i].id == bodyId) { bodyCol[i].style.display = 'block'; } else { bodyCol[i].style.display = 'none'; } } } 
 .tabUnsel:hover { text-decoration: underline; } .tabUnsel { text-align: center; vertical-align: central; padding: 5px 10px 5px 10px; white-space: nowrap; cursor: pointer; background-color: #f0f0f0; border: #898c95 solid 1px; border-radius: 5px 5px 0px 0px; } .tabSel { text-align: center; vertical-align: central; padding: 5px 10px 5px 10px; white-space: nowrap; background-color: #ffffff; border: #898c95 solid 1px; border-bottom: 0; border-radius: 5px 5px 0px 0px; } 
 <table style="width: 500px; font-family: verdana; font-size: 11px;" cellspacing="0"> <tr> <td style="border-bottom: #898c95 solid 1px;">&nbsp;&nbsp;</td> <td id="tab1" class="tabSel" onclick="tabClick(this,'body1');">Tab 1</td> <td style="border-bottom: #898c95 solid 1px;">&nbsp;</td> <td id="tab2" class="tabUnsel" onclick="tabClick(this,'body2');">Tab 2</td> <td style="border-bottom: #898c95 solid 1px;">&nbsp;</td> <td id="tab3" class="tabUnsel" onclick="tabClick(this,'body3');">Tab 3</td> <td style="width: 100%; border-bottom: #898c95 solid 1px;">&nbsp;</td> </tr> <tr> <td style="border: #898c95 solid 1px; border-top: 0; padding: 10px;" colspan="7"> <div id="body1" style="width:100%; min-height: 300px;"> Tab 1 content </div> <div id="body2" style="width:100%; min-height: 300px; display: none;"> Tab 2 content <br/> <img src="http://tropicalfarm.byethost13.com/tabs/img1.jpg" /> <img src="http://tropicalfarm.byethost13.com/tabs/img2.jpg" /> </div> <div id="body3" style="width:100%; min-height: 300px; display: none;"> Tab 3 content </div> </td> </tr> </table> 

try to add this to your empty tap style for example 尝试将其添加到您的空点击样式中

 empty-tap{
  min-height: 500px; 
   height:auto !important; 
   height: 500px;
}

the source here 这里的来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM