CSS Menu bar, Align it to center or full width.

Discussion in 'CSS' started by oskars, May 28, 2012.

  1. #1
    Hello.
    I'm having a menu made in CSS that i would like either to be aligned to the center or making it 100% width so it gets re-sized automatically depending on screen size. Currently it's either fitting perfect or there is space right to it as it's aligned to the left (depends on what screen resolution i use).

    The code is below. I tried to change the "left" things to "center" but didn't help. Thanks!

    .clsSubNav { 
    	padding-top:0px;
    }
    .clsListingHead {
    	padding-top:20px;
    	min-height:56px;
    	_height:76px;
    }
    .clsListingHead h2 { 
    	font-family:Impact; 
    	font-size:22px; 
    	font-weight:normal; 
    	color:#676768;
    }
    .clsSubMenu{
    	overflow:hidden;
    	zoom:1;
    	_height:1%;
    	_overflow:visible;
    }
    	.clsSubMenu li{
    		
    		float:left;
    		
    	}
    			.clsSubMenu li a{
    			background:url(../../images/screen_gray/bg-menutoright.png) no-repeat right top;
    	      		padding-left:14px;
                height:46px;
                line-height:46px;
                position: relative;
                display:table;
    
               
    		border-left:1px solid #c2c2c2;
                float:center;
            }
                .clsSubMenu li a span{
                    background:url(../../images/screen_gray/bg-menutoleft.png) no-repeat left top;
                    color:#000;
                    font-family:"Segoe UI";
                    font-weight:normal;
                    font-size:16px;
                    padding:0 31px 0 17px;
                    height:46px;
                    line-height:46px;
                    position: relative;
                    display:table;
                    border-right:1px solid #c2c2c2;
                    float:center;
                    
    
                    
                }
    		
    		.clsSubMenu li a:hover, .clsSubMenu .clsActiveListing a{
    			background:url(../../images/screen_gray/bg-menulefthover.png) no-repeat left top;
    		}
    			.clsSubMenu li a:hover span, .clsSubMenu .clsActiveListing a span{
    				background:url(../../images/screen_gray/bg-menutorighthover.png) no-repeat right top;
    				color:#000;
    			}
    Code (markup):

     
    oskars, May 28, 2012 IP
  2. MarkTheUser

    MarkTheUser Member

    Messages:
    206
    Likes Received:
    0
    Best Answers:
    4
    Trophy Points:
    26
    #2
    Im in a hurry and cant really stufy your code but have you tried margin: auto; ?
     
    MarkTheUser, May 28, 2012 IP
  3. oskars

    oskars Active Member

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    65
    #3
    Hi
    Yeah i did and didn't work. Maybe i need to remove something else before or so?
    Thank you
     
    oskars, May 29, 2012 IP
  4. MarkTheUser

    MarkTheUser Member

    Messages:
    206
    Likes Received:
    0
    Best Answers:
    4
    Trophy Points:
    26
    #4
    It would really help if i could see your html that this css is used for. Without the html i cant really tell whats what.
     
    MarkTheUser, May 30, 2012 IP
  5. oskars

    oskars Active Member

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    65
    #5
    Hi
    It's a .tpl file and the code is
    <div id="selSubNav" class="clsSubNav">
        <ul id="selSubMenu" class="clsSubMenu">
    
    							<li class="clsLiFirst">
    					<a href="/listing/featured/"><span>Featured</span></a>
    				</li>
    							<li class="">
    					<a href="/listing/newlisting/"><span>New Listings</span></a>
    				</li>
    							<li class="">
    					<a href="/listing/mostactive/"><span>Most Active</span></a>
    				</li>
    							<li class="">
    					<a href="/listing/endingsoon/"><span>Ending Soon</span></a>
    				</li>
    							<li class="">
    					<a href="/listing/justsold/"><span>Just Sold</span></a>
    				</li>
    							<li class="">
    					<a href="/listing/endedunsold/"><span>Ended Unsold</span></a>
    				</li>
    
    			                                <li class="">
    					<a href="/tags/"><span>Browse</span></a>
    				</li>
    	
    																								
    																					</div>
    				
    			
    			
    	
    Code (markup):
    Thank you!
     
    oskars, May 30, 2012 IP
  6. Darthmaul

    Darthmaul Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    38
    #6
    Have you tried the margin: auto on .clsSubNav? Also, you could always do this:

    <div id="selSubNav" class="clsSubNav" align="center">
     
    Darthmaul, May 31, 2012 IP
  7. oskars

    oskars Active Member

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    65
    #7
    Yeah i tried that but didn't work either.. Thanks anyway :)
     
    oskars, May 31, 2012 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    What is up with your formatting?
     
    NetStar, May 31, 2012 IP
  9. oskars

    oskars Active Member

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    65
    #9
    What do you mean?
     
    oskars, May 31, 2012 IP
  10. akhileshbc

    akhileshbc Active Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    5
    Trophy Points:
    75
    #10
    I think, he meant to say that your code need some indenting.

    Use some of these to get your code(existing code) properly formatted:
    http://cssbeautify.com/
    http://infohound.net/tidy/

    And next time, while coding, make sure you properly indent the code which will greatly helps in readability.

    And regarding your issue, can you please post a screenshot of the problem.
     
    akhileshbc, Jun 1, 2012 IP
  11. oskars

    oskars Active Member

    Messages:
    133
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    65
    #11
    Solved it, not sure how tough.. but it's working :)
     
    oskars, Jun 1, 2012 IP
  12. akhileshbc

    akhileshbc Active Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    5
    Trophy Points:
    75
    #12
    Share the solution with us. :)
     
    akhileshbc, Jun 1, 2012 IP