Forums

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

Home Forums CSS Styling h2 with background

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #40911
    Gizburdt
    Member

    Hi,

    I’m working on a client project and I would like to do this:
    https://www.dropbox.com/s/3drqs9f3r566nao/wb.jpg

    The only thing wrapping the text is a h2. Does anyone know how to do this?

    Thanks!

    #115024
    Paulie_D
    Member

    As I recall this has come up before but I don’t think anyone ever found a simple solution.

    #115025
    Gizburdt
    Member

    Haha ok, that’s why I posted it here, because I couldn’t fin a solution. Can you give me the link of the previous post?

    #115026
    Paulie_D
    Member

    I tried searching but it’s such a vague subject…I’ll keep looking.

    #115029
    Gizburdt
    Member

    It would be better without the spans, because the text is inserted by a user in a input field.

    #115030
    robertallen
    Participant

    I tried doing something like this…

    div class=h2_wrapper
    div class=h2_background /div
    h2 Testing 1 2 3 /h2
    /div

    Forgive me, the code feature just doesn’t seem to work for me.

    Then giving the h2_background a background color of #000 and an opacity of .5

    Then I tried to absolute position the h2 element to be over it.

    Didn’t work so hot, but I’m still learning.

    #115032
    Paulie_D
    Member

    I’m pretty sure no-one ever came up with a solution that didn’t involve extra mark-up/HTML & or JS.

    #115034
    Gizburdt
    Member

    Thanks guys!

    #115042
    Nosenation
    Member

    Why can’t you just use something like that, without JS?:

    h2 {
    display: inline-block;
    color: white;
    text-align: center;
    text-transform: uppercase;
    background: rgba(0,0,0,0.7);
    padding: 5px;
    }

    #115048
    Nosenation
    Member

    Ok, my fault. Didn’t saw line break :).

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