Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By Ronald Roe

Thread: Question ? Setting The Width Of An HTML <a> Tag To A %, Not PX. Having An Issue.

  1. #1
    Junior Member MartyBoi's Avatar
    Join Date
    Sep 2011
    Location
    Saginaw MI
    Posts
    27
    Member #
    29177

    Question ? Setting The Width Of An HTML <a> Tag To A %, Not PX. Having An Issue.

    I am trying to set the with of an HTML <a> Tag with a %, not a PX. But for some reason I cannot use a % when defining the width of an HTML <a> Tag. PX and EM work, but not %. Is this normal?

    primary-menu ul li a {
    width:120px;
    }

    But want to change the PX to %. I know how to do the math, but when I change to percent it doesn't work.

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    You'll have to set the display property to inline-block.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Junior Member MartyBoi's Avatar
    Join Date
    Sep 2011
    Location
    Saginaw MI
    Posts
    27
    Member #
    29177
    Quote Originally Posted by Ronald Roe View Post
    You'll have to set the display property to inline-block.
    I have it set to block.... That should work right?

  5. #4
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    If the anchor is set to block, it should
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  6. #5
    Junior Member MartyBoi's Avatar
    Join Date
    Sep 2011
    Location
    Saginaw MI
    Posts
    27
    Member #
    29177
    Quote Originally Posted by Ronald Roe View Post
    If the anchor is set to block, it should
    primary-menu ul li {
    float: left;
    }
    primary-menu ul li a{
    display:block;
    width:120px;
    }
    Last edited by MartyBoi; Jun 06th, 2014 at 12:25 PM.

  7. #6
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Ah. The li will require a defined width, or the anchor won't have a width to calculate against.
    MartyBoi likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  8. #7
    Junior Member MartyBoi's Avatar
    Join Date
    Sep 2011
    Location
    Saginaw MI
    Posts
    27
    Member #
    29177
    Quote Originally Posted by Ronald Roe View Post
    Ah. The li will require a defined width, or the anchor won't have a width to calculate against.
    Do I have to display li as a block as well?

  9. #8
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    IIRC, li are block-level by default.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  10. #9
    Junior Member MartyBoi's Avatar
    Join Date
    Sep 2011
    Location
    Saginaw MI
    Posts
    27
    Member #
    29177
    Quote Originally Posted by Ronald Roe View Post
    IIRC, li are block-level by default.
    So primary-menu ul li {
    float:left;
    width:120px;
    }
    primary-menu ul li a {
    display:block;
    width:120px;
    }

    Is okay?


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:00 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com