How to center navigation bar, main content and footer
P粉165823783
P粉165823783 2023-09-16 13:52:33
0
1
1096

I am very new to the field of network coding and need some help. I'm making a web page for a local sports team and since their web page doesn't look that great and Wordpress isn't very user-friendly, I thought it might be easier to try coding it myself.

I can't enter the navigation bar, main content, and footer on the page. I want the navigation bar, main content, and footer to be entered and only 80% wide so you see some background with pictures of athletes from sports teams)

#footerWrapper { max-width: 80%; max-height: 5%; margin-bottom: 20px; line-height: 30px; font-size: 0.9em; border: 0 solid #ddd; border-bottom-color: #3F8444; border-width: 1px 0;} /*Positions and Margins*/ .image { position: absolute; top:100px; left:100px; } .image-1 { position: absolute; top:20px; right: 100px; } header{ text-align: center; margin-top: 100px; margin-bottom: 100px; } main{ width: 80%; display: flex; flex-direction: row; justify-content: space-evenly; align-items: center;} footer{ position: static; left: 0; bottom: 0; width: 80%; height: 5%;} p {margin-left: 5px; margin-right: 5px;} /*Navigation*/ ul { display: flex; flex-direction: row; align-items: center; list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #04AA6D; width: 80%; } /*li {float: left;}*/ li a, .dropdown li a { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover, .dropdown:hover .dropbtn {background-color: #111;} li.dropdown { display: inline-block;} .dropdown-content { display:none; position: absolute; background-color: #04AA6D; color: white; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0,.2); z-index: 1; } .dropdown-content a { color: white; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } .dropdown-content a:hover {background-color: #111;color: white;} .dropdown:hover .dropdown-content { display: block; }  

Sports Team

Contact Us

Sports Team email

I tried many different CSS styles float, margin, flex, grid, etc.

P粉165823783
P粉165823783

reply all (1)
P粉473363527

here you go! What a great start. Looks like you're hanging out. I highly recommend looking into something liketailwindcssorbootstrap.

These frameworks help handle most of the tedious fine-tuning. You won't actually have much CSS in your file, you can just add class names. Something likeclass="m-auto d-flex text-center"will replace all your css.

These frameworks are based on classes, which is my next recommendation. You should use classes or IDs for everything. This allows you to write cleaner, more organized code. You should have:

 

What if you need to have multipleulon your site, but they need to be different colors or one should not be centered?

Here's how to center existing code: Margins on navigation bar and main bar should be auto instead of 0.

main { width: 80%; display: flex; flex-direction: row; justify-content: space-evenly; align-items: center; margin: auto; } ul { display: flex; flex-direction: row; align-items: center; list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #04AA6D; width: 80%; }
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!