Results 1 to 10 of 10

Thread: Center Solid Block Menu

  1. #1
    Join Date
    Aug 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Center Solid Block Menu

    I am trying to center my solid block menu. Here is my .css code :


    <style type="text/css">

    /*Credits: Dynamic Drive CSS Library */
    /*URL: http://www.dynamicdrive.com/style/ */

    .solidblockmenu li{
    display: inline;
    }

    .solidblockmenu{
    margin: 0;
    padding: 0;
    float: center;
    font: bold 13px Arial;
    width: 100%;
    border: 1px solid #625e00;
    border-width: 1px 0;
    background: black url(blockdefault.gif) center center repeat-x;
    list-stlye:none;
    }

    .solidblockmenu li{
    display: inline;
    }

    .solidblockmenu li a{
    float: center;
    color: white;
    padding: 11px 13px;
    text-decoration: none;
    border-right: 1px solid white;
    }

    .solidblockmenu li a:visited{
    color: white;
    }

    .solidblockmenu li a:hover, .solidblockmenu li .current{
    color: white;
    background: transparent url(blockactive.gif) center center repeat-x;
    }

    </style>





    I would greatly appreciate any help.

  2. #2
    Join Date
    Jul 2007
    Location
    California
    Posts
    177
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I think you want to center the

    .solidblockmenu li ul{
    either text-align:center
    or maybe try float:center?

    Just a guess... but I'm assuming you want the blocks centered within the menu bar?

  3. #3
    Join Date
    Aug 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, i want to center the blocks within the menu bar. All of my float options are centered already in my code above, so that did not work. I even tried adding:
    .solidblockmenu li ul{
    float: center;
    }
    It did not work either.

  4. #4
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The option float: center; doesn't exist, only text-align: center;.
    By what I understand of what you asked, maybe you could try to use the same "artifact" used to center a whole page in the viewport:
    Code:
    .solidblockmenu {
        ...
        margin: 0 auto;
        ...
    }
    This should work on FF. For IE, try:
    Code:
    .solidblockmenu {
        ...
        margin: 0 auto;
        text-align: center;
        ...
    }
    And then:
    Code:
    .solidblockmenu ul li {
        ...
        text-align: left;
        ...
    }
    Again, I'm not sure if this actually works, it's just some piece of code I used to center my page in the viewport, and I adapted to what I think is your case. I'm assuming that .solidblockmenu is a class for a DIV, I don't know if it would work for anything else than a DIV.
    Should this solution work, let me know. Also, modify the 0 in margin: 0 auto; and the left in text-align: left; if needed. What should do the magic is the margin: 0 auto; (for FF) and the text-align: center; (for IE).

  5. #5
    Join Date
    Aug 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the help, but no it did not work.

  6. #6
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I forgot to say that you should probably specify a width for the piece of code I sent you to work. Otherwise, there's no basic information to define how large would the auto margin be.
    Please post your HTML code as well, so we can see what you're doing and why it's not working. If it's too big, please post on Pastebin so we can follow up with it.

  7. #7
    Join Date
    Aug 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I posted the code here: http://pastebin.com/m1d689e41
    Last edited by jcmiller; 08-16-2007 at 08:06 PM. Reason: correct link

  8. #8
    Join Date
    May 2007
    Location
    Viet Nam
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Simply can use the <center> html tag for the blockmenu, it will be centered faster than you use css.

    http://vn.worldcybergames.com/

    Tested and worked fine.

    You can't use the text-align: center to center the menu options becoz IE doesn't understand that the ul and li is the text. It the reason why there are no many sites have the menu centered.

    Another way, using

    margin: 0px auto; for the ul instead of the block (have not tested yet)

  9. #9
    Join Date
    Aug 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    When I first viewed it in IE it worked, but now it doesn't. Here is part of my code:
    Code:
            <div class="ddcolortabs style5" id="colortab">
    
    <div id="blockmenu" >
    </center>
    	<ul class="solidblockmenu style5 style37">
    <li ><a href="http://www.dynamicdrive.com/" class="left ">Home</a></li>
    <li><a href="http://www.dynamicdrive.com/style/" rel="mylife_drop">My Life</a></li>
    <li><a href="http://www.dynamicdrive.com/forums/">Photos</a></li>
    <li><a href="http://tools.dynamicdrive.com" rel="cis55_drop">CIS 55</a></li>
    <li><a href="http://www.javascriptkit.com/" rel="webdesign_drop">Web Design</a></li>
    <li><a class="right"  href="http://www.cssdrive.com" rel="contactme_drop"> Contact Me</a></li>
    </ul>
    </center>
    </div>

    Here is my .css file:
    Code:
    <style type="text/css">
    
    /* ######### Style for Drop Down Menu ######### */
    
    .dropmenudiv_a{
    position:absolute;
    top: 0;
    border: 0px solid #980E10; /*THEME CHANGE HERE*/
    border-top-width: 8px; /*Top border width. Should match height of .ddcolortabsline above*/
    border-bottom-width: 0;
    font:normal 14px Cambria;
    line-height:18px;
    z-index:100;
    background-color: #FFFFFF;
    width: 200px;
    visibility: hidden;
    }
    
    
    .dropmenudiv_a a{
    width: auto;
    display: block;
    text-indent: 5px;
    border-top: 0 solid #FDE8E9;
    border-bottom: 1px solid #FDE8E9; /*THEME CHANGE HERE*/
    padding: 2px 0;
    text-decoration: none;
    color: white;
    }
    .dropmenudiv_a a.sub_bottom{
    width: auto;
    display: block;
    text-indent: 5px;
    border-top: 0 solid #678b3f;
    border-bottom: 0px solid #678b3f; /*THEME CHANGE HERE*/
    padding: 2px 0;
    text-decoration: none;
    color: white;
    background: transparent url(blockactive.gif) bottom left no-repeat;
    }
    
    * html .dropmenudiv_a a{ /*IE only hack*/
    width: 100&#37;;
    }
    
    .dropmenudiv_a a:hover{ /*THEME CHANGE HERE*/
    background-color: #8a3c3d;
    color: white;
    }
    /*Credits: Dynamic Drive CSS Library */
    /*URL: http://www.dynamicdrive.com/style/ */
    
    .solidblockmenu{
    
    margin: 0px auto;
    padding: 0;
    float: right;
    font: bold 13px Arial;
    text-align: center;
    width: 100%;
    border: 0px solid #625e00;
    border-width: 0px 0;
    background: transparent url(blockdefault.gif) center center repeat-x;
    }
    
    .solidblockmenu li{
    display: inline;
    }
    
    .solidblockmenu li a{
    float: right;
    color: white;
    padding: 9px 11px;
    text-decoration: none;
    border-right: 1px solid white;
    }
    
    
    .solidblockmenu li a:visited{
    color: white;
    }
    
    #blockmenu a#current{background: transparent url(blockactive.gif) top right no-repeat;}
    
    
    
    .solidblockmenu li a:hover, .solidblockmenu li .current{
    color: white;
    background: transparent url(blockactive.gif) center center repeat-x;
    }
    
    
    .solidblockmenu ul li {
        text-align: center;
    	margin: 0px auto;
    }
    
    
    
    
    
    </style>
    Thanks for the suggestion. I must have made an error. I really appreciate your help.

  10. #10
    Join Date
    May 2007
    Location
    Viet Nam
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Wrong html code

    Code:
    <div id="blockmenu" >
    </center>
    	<ul class="solidblockmenu style5 style37">
    <li ><a href="http://www.dynamicdrive.com/" class="left ">Home</a></li>
    <li><a href="http://www.dynamicdrive.com/style/" rel="mylife_drop">My Life</a></li>
    <li><a href="http://www.dynamicdrive.com/forums/">Photos</a></li>
    <li><a href="http://tools.dynamicdrive.com" rel="cis55_drop">CIS 55</a></li>
    <li><a href="http://www.javascriptkit.com/" rel="webdesign_drop">Web Design</a></li>
    <li><a class="right"  href="http://www.cssdrive.com" rel="contactme_drop"> Contact Me</a></li>
    </ul>
    </center>
    </div>
    you should use:


    Code:
           <div class="ddcolortabs style5" id="colortab">
    
    <center><div id="blockmenu" >
    
    	<ul class="solidblockmenu style5 style37">
    <li ><a href="http://www.dynamicdrive.com/" class="left ">Home</a></li>
    <li><a href="http://www.dynamicdrive.com/style/" rel="mylife_drop">My Life</a></li>
    <li><a href="http://www.dynamicdrive.com/forums/">Photos</a></li>
    <li><a href="http://tools.dynamicdrive.com" rel="cis55_drop">CIS 55</a></li>
    <li><a href="http://www.javascriptkit.com/" rel="webdesign_drop">Web Design</a></li>
    <li><a class="right"  href="http://www.cssdrive.com" rel="contactme_drop"> Contact Me</a></li>
    </ul>
    
    </div></center>

Bookmarks

Posting Permissions

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