DavidHortvik Posted January 11, 2021 Share Posted January 11, 2021 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) If I don't set it inline, in some of my text blocks, the background looks horrible because it's the whole block: 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: 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
tuanphan Posted January 13, 2021 Share Posted January 13, 2021 You want this text has background + center? CUSTOMER FAVORITES Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
DavidHortvik Posted January 13, 2021 Author Share Posted January 13, 2021 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
tuanphan Posted January 17, 2021 Share Posted January 17, 2021 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. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
DavidHortvik Posted January 17, 2021 Author Share Posted January 17, 2021 Awesome, thank worked! Thank you very much 🙂 Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.