1

I have a front end project where I have a square item over an image . My square is suppossed to be fully red but losses opacity . This is how the square looks like in my page instead of being fully red : enter image description here My code :

.html,.body{ background-size: cover; } body{ overflow-x: hidden; margin:0; background: rgba(0, 0, 0, 0.1); } .welcome-container{ position: relative; top:0px; left: 0px; width:100%; height:550px; margin:0px; background-position: center; background-repeat: no-repeat; background-size: cover; } .welcome-pic{ position: relative; } .welcome-pic img{ background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('file:///Volumes/Animus/Jon/Dropbox/website/hellcity.jpg'); } .ds-square{ background-color:red; height: 50px; width:50px; position: absolute; top: 2px; left: 2%; opacity:1; } .welcome-pic img { width:100%; height:550px; opacity: 0.8; } .inside-pic{ position:absolute; top:30%; left:50%; font-size: 60px; transform: translate(-50%, -50%); } .inside-pic h3{ font-size:18px; }
<div class = "welcome-container"> <div class = "welcome-pic"> //my square <div class="ds-square"> </div> <img src = "IMAGES/welcome_pic.jpg" alt="#"> <div class = "inside-pic"> FLY WITH DS <br/> AIRLINES <h3>Flights from or towards Athens ! Fly secure and comfortable with us! </h3> </div> </div> </div>

Trying opacity:1; on the square does not change the result . I would appreciate your help with this simple task . Thank you in advance

5
  • Your code snippet doesnt seem to be working Commented Jul 23, 2020 at 14:50
  • Child opacity cannot overrule parent opacity. Even if the square has opacity: 1, it will appear translucent if any of its parents have opacity < 1. Commented Jul 23, 2020 at 14:52
  • @Gershom Isn't there any way to change this ? Commented Jul 23, 2020 at 14:52
  • You need to make sure the square and all its parents have opacity: 1 Commented Jul 23, 2020 at 14:53
  • You also need to make sure the square isn't covered by a translucent element - this will cause the square to appear translucent, when really it is covered Commented Jul 23, 2020 at 14:54

1 Answer 1

1

.html,.body{ background-size: cover; } body{ overflow-x: hidden; margin:0; background: rgba(0, 0, 0, 0.1); } .welcome-container{ position: relative; top:0px; left: 0px; width:100%; height:550px; margin:0px; background-position: center; background-repeat: no-repeat; background-size: cover; } .welcome-pic{ position: relative; } .welcome-pic img{ background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('file:///Volumes/Animus/Jon/Dropbox/website/hellcity.jpg'); } .ds-square{ background-color:rgba(255,0,0,0.4); height: 50px; width:50px; position: absolute; top: 2px; left: 2%; opacity:1; } .welcome-pic img { width:100%; height:550px; opacity: 0.8; } .inside-pic{ position:absolute; top:30%; left:50%; font-size: 60px; transform: translate(-50%, -50%); } .inside-pic h3{ font-size:18px; }
<div class = "welcome-container"> <div class = "welcome-pic"> //my square <div class="ds-square"> </div> <img src = "IMAGES/welcome_pic.jpg" alt="#"> <div class = "inside-pic"> FLY WITH DS <br/> AIRLINES <h3>Flights from or towards Athens ! Fly secure and comfortable with us! </h3> </div> </div> </div>

Sign up to request clarification or add additional context in comments.

1 Comment

It did not help . Thank you still

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.