简体   繁体   中英

How can I make an element take up the width of the window inside of the width of its parent?

I need to edit this #block only
Finally I need to show the table in full screen with width 100%

How can I make the div#block to get outside the 2 parent divs row & container?

<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>

You can increase the width to 140% and use margin-left: -20% to align it.

 .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> 

You can use 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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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