Results 1 to 3 of 3

Thread: [RESOLVED] [CSS] Setting width on items in <nav>

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,712

    Resolved [RESOLVED] [CSS] Setting width on items in <nav>

    I'm wanting to set the width of my elements inside my <nav> tag. Currently this is my HTML:
    HTML Code:
    <nav>
    	<a href='#'><span id='active'>Home</span></a>
    	<a href='download.html'>Download</a>
    	<a href='library.html'>Library</a>
    	<a href='forum.html'>Forums</a>
    </nav>
    This is what I'm trying:
    Code:
    nav {
    	width: 100%;
    }
    nav a {
    	text-align: center;
    	width: 25%;
    }
    What I'm expecting to happen is the links will be 1/4 the size of the navigation, but that's not happening. Currently all the links are aligned to the left of the nav element.
    Last edited by dday9; Jul 1st, 2014 at 02:40 PM.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: [CSS] Setting width on items in <nav>

    You can either set the anchors to display as inline-block, or you can set them to display as block and float them. Both of those should make your elements line up one next to the other.

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,712

    Re: [CSS] Setting width on items in <nav>

    Ah ok. I don't know why I didn't think of setting the display... Thanks kfcSmitty!
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

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



Click Here to Expand Forum to Full Width