Site logo

Archived topic

Background style for hero

8 replies · Started by Norman on April 16, 2020

Viewing posts 1–9 of 9

Hey there,
i tried to add a background color to h1 headline in the hero.

This is what I added to the Header Element:


<h1 class="title-background">{{post_title}}</h1>

and this is the css I added:

h1.title-background {
    background-color: #00af95;
    color: #fff;
    padding: 5px

My problem: The background color spans the whole column and not only the text. How do I fix that?

You need to give the div that contains the h1 tag a fixed width.

.inside-page-hero {
width: 500px;
margin-left: auto;
margin-right: auto;
}

Hi there,

in your h1.title-background CSS include the display: inline; property

Hi David,

I think that only works if you don't have another block after the title. If you have h1 tag and then maybe h2 tag under it, then the two would go side by side with inline display.

Thats correct - the users site only has the H1 :)

Thx for the feedback.
The inline option does nothing.
And the fixed width is obviously not dynamic. So, if a post has a shorter title, it will still look a bit weird.

Your CSS is broken:

h1.title-background {
    background-color: #00af95;
    color: #fff;
    display: inline padding:10px;
}

it should look like:

h1.title-background {
    background-color: #00af95;
    color: #fff;
    display: inline;
    padding:10px;
}

Oh lol. Thank you for catching that. Must have been blind. Works now! :)

Glad to be of help

This archived topic is closed to new replies.