Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Inline background breaks the text alignment


DavidHortvik

Question

Site URL: https://www.ekustik.cz

Hi all,

I would like to ask you for a help with background color for my h2 headers. When I set a background with the following code, it breaks the text alignment and all the text is suddenly on the far left in the text block.

h2 { display: inline;

  background-color: #B58D3C; 

}

It looks like this: (note that i set the text alignment in the block to the center)image.thumb.png.c48a8d571c1dafb706fb0738f61e6a9a.png

If I don't set it inline, in some of my text blocks, the background looks horrible because it's the whole block:

image.png.64901ff6c5303859be7d95b3057974e4.png

My goal is to have the background only behind the text. however, I want to have some of the text block with left, right or center text alignment. For example, like we can see here:

image.png.b8523f12aaae0fbae9e9736c415c0dbb.png

image.png.1b8256e844b772a7de8bab5e8380aded.png

Is there any code for the display to be inline. but it does not break the text alignment of the whole h2 style?

Thank you, David

Link to comment
  • Answers 4
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Posted Images

4 answers to this question

Recommended Posts

  • 0

Hi, yes, exactly.

I solved it by creating h4 style that has the golden background and then inserted code block with:

<h4> TEXT </>

However, this still work only when:

display:inline

That means that the text can't be aligned otherwise than on the left. I think I am missing something important. Do you think there is way how to set the colored background of just the text so it does not interfere with the text alignment at all?

Link to comment
  • 0
On 1/14/2021 at 2:57 AM, DavidHortvik said:

Hi, yes, exactly.

I solved it by creating h4 style that has the golden background and then inserted code block with:

<h4> TEXT </>

However, this still work only when:

display:inline

That means that the text can't be aligned otherwise than on the left. I think I am missing something important. Do you think there is way how to set the colored background of just the text so it does not interfere with the text alignment at all?

Keep the current code & add this to Design > Custom CSS

div#block-yui_3_17_2_1_1610468698876_27228>div {
    text-align: center;
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...