Noha_Farid Noha_Farid - 3 months ago 20
CSS Question

W3.CSS how to make container centered inside another container

I'm using the w3.css, I wanted to make a colored background with width 100%,

and inside it another box with width 80% which will contain the text, so I used the following:

<div class="w3-container w3-light-green">
<div class="w3-container w3-sand w3-center" style="width:80%">
test
</div>
</div>


The problem is that the second container with the 80% width is not centered in the page although I used w3-center.
I noticed that w3-center only centers the text, but the container itself isn't centered, so how can I center the container block?

Answer

I think this should work.. Try It..

<div class="w3-container w3-light-green">
<div class="w3-container w3-sand w3-center" style="width:80%;margin:auto;">
test
</div>
</div>
Comments