1

I want unclickable overlay on the top of the image

codepen link on the comment section

html:

<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />

css:

img{
  width:100px;
  height:100px;
  cursor: not-allowed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 1000;

}

with grey opacity on the top of the image

something like this https://prnt.sc/10pm4zm

3

2 Answers 2

1
<div class="container">
  <img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
  <div class="overlay"></div>
</div>

And css to be

img {
  width: 100px;
  height: 100px;
}
.container {
  width: 100px;
  height: 100px;
  position: relative;
  pointer-events: none;
  }
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: rgba( 0, 0, 0, 0.5 );
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the answer but I am still in problem . The container is still clickable and unclickable icon in not showing up i.sstatic.net/HkYpY.png . Here is the code on the codepen codepen.io/ranjan-raj-shrestha/pen/yLVdjLx#_=_
see the edited code. Move the pointer-events to .container
0

You can add another div after the tag. and give it the css as follows

img{
  width:100px;
  height:100px;
  
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  

}
div{
  position:absolute;
  width:50px;
  height:30px;
  cursor: not-allowed;
  top: 80px;
  left: 10px;
  right: 0;
  bottom: 0;
  background-color: grey;
  z-index: 1000;
  opacity: 0.5;
}
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
<div></div>

Furthermore you can adjust opacity and the size of the overlay unclickable div accordingly

4 Comments

Thank you for the answer can you help me to fill the buttom div cover the image codepen.io/ranjan-raj-shrestha/pen/yLVdjLx
please clearify, you want the bottom div to overlay or cover your image?
well, remove the <div> tag. then the bottom <p> tag will cover the image
According to the source code given in: codepen.io/ranjan-raj-shrestha/pen/yLVdjLx the solution works. you can send me the code for prnt.sc/10po9jx so i can check that out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.