Grow your CSS skills. Land your dream job.

How to create expanding tabs?

  • # May 26, 2009 at 3:39 pm

    I haven’t started this website yet, but I want to make a website that when a user clicks on a link (set up at the top of the page, like tabs), I want it to expand from roughly 100px to 200 or 250px – does that make sense? I have no idea how to code that, or what to search on Google for, to figure it out. I know how to set up tab links like on this website (CSS-Tricks – look at the top of this page), but I just don’t know how I would expand them.

    Please help!

    # May 26, 2009 at 3:58 pm

    I suppose you could do that with some form of jquery, it really depends on what you’re trying to accomplish though.

    Are you expanding in one direction (ie, width or height) or multiple directions (ie, width AND height)? Would the content within the tab be replaced with something else?

    Always think about usability as well. Is this something that the average user going to the site is going to even understand?

    # May 26, 2009 at 4:44 pm

    Good questions…

    I only want it to expand horizontally roughly by 100 pixels just to emphasize that they are in that "tab". The text will be the same within the link tab, but I just want it to expand horizontally. It is a more design emphasized website, so they do need this feature. Does that help?

    # May 26, 2009 at 4:54 pm

    Ahhhhhh, so you’re simply wanting a "current" state?

    That’s easily done with CSS.

    <ul>
    <li>About</li>
    <li>Something Else</li>
    <li class="current">Oh Snap, Current</li>
    <li>One More</li>
    </ul>

    # May 26, 2009 at 6:04 pm

    I loved your reply – super simply and awesome funny – thanks for the help :)

    Now for another question…

    I am currently working on the following site: meandmyback.com/linearstars and I’m having issues with just aligning the "|" pieces in the middle of my link areas. I just barely started on it, but if you could help me out, that would be great. Here’s the HTML and CSS for it so far:

    Code:
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




    and now the CSS:

    Code:
    font { font:Arial, Helvetica, sans-serif;}
    body {background:#FFF;}

    #align {background: url(../images/shadow.gif); width:1126px; background-repeat:repeat-y; margin:50px auto;}
    #container {width: 1024px; height:640px; margin:50px auto; background:#FFF; border: solid 1px #666;}
    #header {float: left; }
    #nav {float:right; margin:0px 0px 0px 35px;}

    .left {float:left;}
    .header {float:left; margin: 25px 25px;}
    .clear {clear:both;}
    .black {margin:0px 5px 12px 5px;}

    # May 26, 2009 at 7:25 pm
    "nchipping" wrote:
    I am currently working on the following site: meandmyback.com/linearstars and I’m having issues with just aligning the "|" pieces in the middle of my link areas.

    That’s because you have:

    Code:
    .black {
    margin:0 5px 12px;
    }

    So the links, which are .black, get pushed up, while the "|" (pipes) don’t get pushed up because they are not .black. I would recommend instead of using pipes in your HTML, use 1px border to keep the border right next to your links.

    Code:
    .black {
    margin:0 5px 12px;
    border-left: 1px solid #000;
    }
    # May 26, 2009 at 7:31 pm

    Good idea — I’ll fix that. Thanks.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".