JSFiddle - React, Tailwind, and code Playground
HTML
<div class=viewport-container>
<iframe class=output-frame frameborder=0 src="404.html"></iframe>
<div class=element-highlight>
<div class=highlight></div>
</div>
</div>
CSS
div.viewport-container {
position: absolute;
top: 50px;
left: 100px;
z-index: 5;
display: block;
box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.14);
box-sizing: border-box;
width: 100%;
height: 100%;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
iframe.output-frame {
background: #fff;
width: 100%;
height: 100%;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
div.element-highlight {
width: 100%;
height: 100%;
display: block;
position: absolute;
top: 0;
left: 0;
z-index: 2;
pointer-events: none;
overflow: hidden;
}
div.element-highlight div.highlight {
display: hidden;
position: absolute;
background: yellow;
opacity: 0.5;
cursor: default;
pointer-events: auto;
}
JavaScript
var viewframe = $('div.viewport-container iframe.output-frame').contents();
viewframe.find('a, p, h2').hover(function(){
var elementWidth = $(this).width();
var elementHeight = $(this).height();
var elementPosition = $(this).offset();
$('div.viewport-container div.element-highlight div.highlight').css({'display':'block','width': elementWidth, 'height': elementHeight, 'top': elementPosition.top, 'left': elementPosition.left});
}, function(){
$('div.viewport-container div.element-highlight div.highlight').css({'display':'none'});
});