简体   繁体   English

td,在div中的宽度为100%,绝对位置

[英]td with width 100% inside div with position absolute

Behavior of code snippet is different in Chrome 51.0.2704.103 and Firefox 47.0.1 . Chrome 51.0.2704.103Firefox 47.0.1 ,代码段的行为有所不同。

Please explain why this happens. 请解释为什么会这样。 Where behavior is correct, where not and why you think so. 行为正确的地方,不正确的地方以及为什么如此。 Thanks. 谢谢。

 div, td { border: 1px solid black; } .container { position: absolute; } .w100Pc { width: 100%; } .nowrap { white-space: nowrap; } 
 <div class="container"> <div>Modal dialog header</div> <table> <tr> <td class="w100Pc">rest of space column</td> <td class="nowrap">content based width column</td> </tr> </table> <div>Here goes main content what should stretch "container" width</div> <div>Modal dialog footer</div> </div> 

Browser render the code differently i guess it's because they follow different standards, i think Firefox is rendering the code currently in you example and to make it look the same in both browsers just add display:block; 浏览器以不同的方式呈现代码,我想这是因为它们遵循不同的标准,我认为Firefox正在呈现您示例中的当前代码,并使其在两个浏览器中看起来相同,只需添加display:block;

 div, td { border: 1px solid black; } .w100Pc { display:block; width: 100%; font-family:'Times New Roman'; } .container { position: absolute; left: 200px } 
 <div style="position: absolute; left:200px"> <table class="w100Pc"> <tr> <td class="w100Pc"> w100Pc </td> <td>buttons</td> </tr> </table> </div> 

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

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