Jump to content

Image Slider: Transparent background that doesn't affect text?


Recommended Posts

PS 1.6.1.7

Default Theme

 

 

I would like to make the text in the Image Slider easier to read via a semi-transparent text background.  I figured out how to put in the semi-transparent background but it applies the opacity to the text as well.  I'd like to keep the text without the opacity but I can't figure out how.

 

I've been scouring a bunch of CSS help websites and most of the answers say to make this change:

 

From: background-color: #ffffff;

To:      background-color: rgba (255, 255, 255, 0.6)

 

(the 0.6 representing the amount of opacity)

 

Whenever I try to do that the background just reverts to clear.  Perhaps I'm not putting this in the correct place?

 

So right now my code is like this and it shows a semi-transparent text background with faded text:

 
#homepage-slider .homeslider-description {
    position: absolute;
    left: 0;
    top: 0;
    margin: 10px;
    padding: 0px 10px;
    background-color: #c0c0c0;
    opacity: 0.8;
    border: 1px solid black;
    width: 40%;
    padding: 2px 10px;
    cursor: pointer; }
 
The CSS sites say it can be done and I'm thinking maybe this slider works a bit differently.  I'm not a codie, so any help would be grrrrrrrrrreat.
 
 
 
Link to comment
Share on other sites

I've encountered this problem before when developing websites. The problem occurs when the text is a child of the box element and it inherits the opacity of the box. The solution is to use separate divs for the box and text so there is no inheritance. For example, change line 39 (in PrestaShop v1.6.1.7) of themes/default-bootstrap/modules/homeslider/homeslider.tpl from:

								<div class="homeslider-description">{$slide.description}</div>

to:

								<div class="homeslider-box"></div>
								<div class="homeslider-description">{$slide.description}</div>

And then add the following to themes/default-bootstrap/css/modules/homeslider/homeslider.css:

  #homepage-slider .homeslider-box {
    background: #000;
    opacity: 0.5;
    width: 100%;
    height: 300px;
    position: absolute;
    top: 0 }

This looks good in the default PrestaShop theme, though I see you're using a custom theme. Adjust the width and height as necessary until it looks good on your website.  

Link to comment
Share on other sites

I had another look at this and I've found a more modern solution since the last time I fixed it. You can remove the extra box div and just apply the following to the #homepage-slider .homeslider-description:

background-color: rgba(0, 0, 0, 0.5)

Maybe that will help, since the box and text will have the same width.

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...