CSS text background color trouble (2 posts)

  1. KasperN
    Posted 2 years ago #

    My site uses a content slider for the home page, and I am trying to add transparent background colour to the text only (so that it wraps around the text itself, and doesn't create a block of colour like it does now).


    <center><img src="/wp-content/uploads/2013/07/skid.png"  class="bigImage" data-animate="rollIn"></img></center>
    <div class="text_1_1" data-ease-type="fadeInUp">3D Conceptual Design</div>
    <div class="text_1_2" data-ease-type="fadeInUp"><p style="line-height: 125%;">Electrolysis cell with integrated gas separator</div></p>


    .section_slider_1 .text_1_1 {width:290px; margin-left:-435px; position:absolute; left:50%; top:124px; font-family:'Open Sans', Arial, Helvetica, sans-serif; font-size:20px; color:#0071b3; background-color:rgba(255,255,255,0.7); text-transform:uppercase;}
    .section_slider_1 .text_1_2 {width:290px; margin-left:-435px; position:absolute; left:50%; top:149px; font-family:'Open Sans', Arial, Helvetica, sans-serif; font-size:22px; color:#ffffff; background-color:rgba(0,113,179,0.6); font-weight:bold; text-transform:uppercase;}

    How it looks now (image)


  2. paulwpxp
    Font hero
    Posted 2 years ago #

    Use <span> which is inline element, not block element.

    	<span>A block of text with many many lines that has Yellow background.</span>
    	<span>A block of text with many many lines that has Red background.</span>

    and assign the background color to the <span>

    div span { background-color: yellow; }
    p span { background-color: red; }

Topic Closed

This topic has been closed to new replies.

About this Topic