css - How do i make all my content centered in html -


i started making page web design class , ran problem. page has navigation bar , picture far. wanted center them both using css.

display: block; margin-left: auto; margin-right: auto 

i used both nav bar , img. want nav bar above image if page gets resized. there anyway in css?

margins center if element has width. css might like:

img{     width:300px;     margin: 0 auto; }  nav{     width:600px;     margin: 0 auto; } 

basic html:

<nav>     <ul>         <li>something</li>         <li>something else</li>     </ul> </nav> <img src="../path-to-file.jpg" alt="image"> 

that center both elements.

as making nav above image... mean overlapping it? or "above" way question above answer?

i can update post if make clear.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -