Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Spacing problem with header

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #205760
    snewman
    Participant

    Hi All,

    Here is my code: http://codepen.io/anon/pen/NqEBNa

    I’m running into a slight problem. You can see that when you hover over “My Website” there is a small space at the bottow (about 4px). I’m not sure why the header is bigger than the contents. Any suggestions? Thanks in advance!

    #205761
    Paulie_D
    Member

    It’s becuase the #header_box div isinline-blockso thewhite-space in the HTML add about 1 character’s space (about .25em) in there.

    There are a number of techniques for eliminating it which you can research but just using block instead ofinline-block will fix it.

    
    div#header_box {
      color: white;
      font-family: Montserrat;
      width: 60%;
      display: block;
      overflow: hidden;
    }
    
    #205845
    snewman
    Participant

    Ok so now I have a new problem. When I make my header_box a block, it places everything I had in the header in the main box.

    I redid the full code here: http://codepen.io/anon/pen/EjGZVO

    See what happens when you make the #header_box into a block? How do I keep it at the top?

    One more quick question, what would be the best way to evenly space out “Web Design, Photography, Resume”? I want to put spaces between each word but still have the whole thing centred.

    Thanks!!!

    #205849
    Paulie_D
    Member

    See what happens when you make the #header_box into a block? How do I keep it at the top?

    You have to clear the floats….there are a number of “clearfix” techniques but a quick one is just to add overflow:hidden to the element.

    One more quick question, what would be the best way to evenly space out “Web Design, Photography, Resume”?

    That’s this

    <h2 id="secondary_title">
    <a href="">Web Design</a>
    <a href="">Photography</a>
    <a href="">Resume</a>
    </h2>
    

    An h2 is 100% wide by default so to center the text add text-align:center, which means you can remove that property from the links themselves.

    Then make the links inline-block. You could add left/right margin to separate them but I prefer left/right padding to increase the hit target area..but that’s up to you.

    #secondary_title {
    text-align: center;
    }
    
    /* styling the secondary title */
    #secondary_title a{
    color: white;
    font-size: 30px;
    font-family: lobster;
    text-decoration: none;
    display: inline-block;
    padding: 0 10px;
    }
    

    I’d also add a :hover state so users can see the interaction.

    http://codepen.io/Paulie-D/pen/XboMKJ

    #205893
    snewman
    Participant

    Paulie, thanks so much for taking the time to help me with this. Honestly, I would have never figured that out. I heard of clearing floats before but that never occurred to me. Thanks!!!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.