Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How can I center my menu?

    Hi.
    I am having difficulty centering my menu for ALL browsers and screen sizes. I am able to center the website, using <div align:center;> under the body tag in the html. However, the menu just stays in the same place, and does not center.
    The link to my site is www.trecall.com..

    Please help!!
    Thank you.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Start with fixing the errors in your markup, see http://validator.w3.org/check?verbos...trecall.com%2F
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I validated the website now. There are no errors. My problem still remains. I cannot get the main animated menu to be in the center of the site on all screen sizes. Please help!

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello suave design,
    Your h1 is floated with nav beside it. Is it actually .main that you want centered?
    To center an element you need three things:
    1. a valid DocType
    2. an element with a width
    3. that elements right/left margins set to auto


    To center main you would need to make your CSS look like this -
    Code:
    .main {	width: /*1280px;*/125em;/*2000*/ 
    /*border:4px solid yellow;*/
    /*margin:0 auto;*/
    /*text-align:center;*/
    margin: 0 auto;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #5
    New to the CF scene
    Join Date
    May 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It's actually .cc_menu that I want to center. I tried doing margin:0 auto; on main, though, and that did not either work. Please help!
    Thank you.

  • #6
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    If you folllow my earlier suggestion on how to center things you might try these changes highlighted in red -
    Code:
    .main {	width: /*1280px;*/125em;/*2000*/ 
    /*border:4px solid yellow;*/
    /*margin:0 auto;*/
    /*text-align:center;*/
    margin: 0 auto;
    background: #f00;
    }
    
    .cc_menu{
    width:/*1290px;*//*99.625em;*//*100%;*/97.5em; 
    /*margin-left:150px;*/
    margin: 0 auto;
    background: #00f;/*9.375em;*/
    /*margin:0:auto;*/
    /*height:591px;*/
    position: relative;
    /*top:/*13.75em;*/
    /*220px;left:/*0.938em;*//*15px;*/	
    font-size:14px;
    text-transform:uppercase;
    color:#fff; 
    overflow:hidden;
    /*border:3px solid green;*/
    }
    The background colors are just for a visual so you can see how things lay. You may want to re-think the width you have on .cc_menu right now.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #7
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Maybe use this demo centering menu items as a guide.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title></title>
            <style type="text/css">
                #linksContainer {
                    margin: 0px auto 0px auto;
                    padding: 0px 0px 0px 0px;
                    width: 900px;
                    overflow: hidden;
                    border: 1px solid red}
                #linksList {
                    list-style-type: none;
                    margin: 0px 0px 0px 0px;
                    padding: 0px 0px 0px 0px;
                    float: left;
                    position: relative;
                    left: 50%}
                #linksList li {
                    float: left;
                    margin: 0px 20px 0px 20px;
                    position: relative;
                    right: 50%}
    
            </style>
        </head>
        <body>
            <div id="linksContainer">
                <ul id="linksList">
                    <li>Link 1</li>
                    <li>Link 2</li>
                    <li>Link 3</li>
                    <li>Link 4</li>
                    <li>Link 5</li>
                </ul>
            </div>
        </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •