Forums

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

Home Forums CSS Header background extending on both sides with empty middle

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35410
    SachaG
    Member

    Here’s the effect I’m trying to accomplish: http://cl.ly/CEBs

    The background on “Read More” is extending out on both sides, but not behind the actual text.

    Looks pretty simple right? In fact I’ve got it working with pseudo-elements, but the only problem is that my current implementation requires a fixed width header and an additional span element. Here’s what my markup looks like:


    Read More


    And here’s my CSS:


    h3{
    overflow:hidden;
    position:relative;
    height:21px;
    }
    h3 span{
    display:block;
    position:absolute;
    left:50%;
    margin-left:-70px;
    }
    h3 span:before, h3 span:after{
    background: url("bg.png");
    content:" ";
    display:block;
    height:14px;
    right:100%;
    width:200px;
    position:absolute;
    top:4px;
    }
    h3 span:after{
    left:100%;
    }

    As you can see, my code requires that the inner span element have a fixed width, which is not very practical. Any way to do this with unknown width elements, and optionally without the extra span?

    #91640
    TheDoc
    Member

    I think you’ll have to use a span. It’s tough because the background behind it is a pattern because if it wasn’t you could just do something like this: http://jsfiddle.net/NX3TX/2/

    #91643
    SachaG
    Member

    I know, that would be the simplest solution, but it’s also kind of cheating… And like you said doesn’t work well with the pattern :(

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