I am using one html web page, Where i have one image. My requirement here is to highlight the portion of image when hover. To achieve the same i used below code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mark up text</title>
<style type="text/css">
.container {
position:relative;
height:455px;
width:606px;
}
<!-- .container div { -->
<!-- position:absolute; -->
<!-- background-image:url(https://wallpaperaccess.com/full/8070136.jpg); -->
<!-- } -->
.container .bg-image {
opacity:0.3;
height:455px;
width:606px;
}
.container div.highlight-region {
height:50px;
width:50px;
opacity:0;
}
.container div.highlight-region:hover {
opacity:1;
}
</style>
</head>
<body>
<div class="container">
<img class="bg-image" src="https://wallpaperaccess.com/full/8070136.jpg" alt="images" style="position:absolute;" />
<div class="highlight-region" style="top:50px;left:50px;background-position: -50px -50px; position:absolute;"></div>
<div class="highlight-region" style="top:150px;left:150px;background-position: -150px -150px; position:absolute; background-image:url('https://wallpaperaccess.com/full/8070136.jpg');"></div>
</div>
</body>
</html>
In this code when i hover on image, It is not highlighting the portion of image, But when i render the same image inside div, It is working as expected and the highlighted portion is sick in any device resolution. How do i achieve the same using img tag as well.
Need help.
You need to sign in to view this answers
Leave feedback about this