Im looking for a solution to place a div (100% screen width and lets say 20% height) on top of iframe which is 100% screen width and 100% screen height It should look like this:
__________________________
|| On top DIV ||
||_______________________||
| |
| Iframe |
| |
|_________________________|
Approach 1: For adding additional div's in an iframe, you need to use a wrapper div, that wraps the contents of your intended div and the iframe into one unit. This way you can display the contents of your div along with the iframe embedding to the document/webpage.
The div can be overlayed over iframe using z-index and absolute positioning. Iframe should have z-index lower than the div having class as overlay. Style the overlay div to the same height and width as the iframe, so that it does not affect the functionality of any other divs.
You can use the CSS position property in combination with the z-index property to overlay an individual div over another div element. The z-index property determines the stacking order for positioned elements (i.e. elements whose position value is one of absolute , fixed , or relative ).
Super simple stuff..
put an iframe, and a header div inside one container div.
set position:relative on the container, and position:absolute and top:0 on the header div.
that should do it.
HTML:
<div class="holder">
<div class="bar"></div>
<iframe class="frame"></iframe>
</div>
CSS:
.holder{
width: 400px;
height: 300px;
position: relative;
}
.frame{
width: 100%;
height: 100%;
}
.bar{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 40px;
}
fiddle
The concept of Rodik answer is good but the implementation is buggy.
put an iframe, and a header div inside one container div.
set position:relative on the container, and position:absolute and top:0 on the header div.
http://jsfiddle.net/eayr9pup/2/
.holder {
width: 400px;
height: 300px;
position: relative
}
.frame {
width: 100%;
height: 100%;
background-color: blue;
}
.bar {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 40px;
background-color: red;
}
<div class="holder">
<iframe class="frame"></iframe>
<div class="bar"></div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With