[英]How can I make an element take up the width of the window inside of the width of its parent?
我只需要編輯此#block
最后,我需要全屏顯示表格,寬度為100%
如何使div#block超出2個父div行和容器?
<html>
<head><style>
.container{
max-width: 80%;
}
.row{
max-width: 90%;
}
#block{
width: 100%; //I need to edit this block only - To show the table in full screen with width 100%
}
</style></head>
<body>
<center>
<div class="container">
<div class="row">
<div id="block">
<table border="1" width="100%">
<tr><td>Hello</td></tr>
</table>
</div>
</div>
</div>
</center>
</body>
</html>
您可以將width
增加到140%
並使用margin-left: -20%
對齊。
.container { max-width: 80%; } .row { max-width: 90%; } #block { width: 140%; margin-left: -20%; }
<center> <div class="container"> <div class="row"> <div id="block"> <table border="1" width="100%"> <tr> <td>Hello</td> </tr> </table> </div> </div> </div> </center>
您可以使用position: absolute
.container { max-width: 80%; } .row { max-width: 90%; } #block { width: 100%; position: absolute; left: 0; }
<center> <div class="container"> <div class="row"> <div id="block"> <table border="1" width="100%"> <tr> <td>Hello</td> </tr> </table> </div> </div> </div> </center>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.