This question has been repeated before and I have tried everything that I have found on the internet.
I have a div 'A' inside iframe and the iframe is inside the wrapper div. When I am trying to fix the div 'A' on the top of the screen in mobile view it works without iframe but with iframe it doesn't work.
Position: fixed doesn't work. I can't add the div to be fixed, outside the iframe dynamically using javascript as it will mess up my app's structure.
Can someone please help? I can't share the whole code. but this is the structure and I can't avoid iframe unfortunately.
Parent page:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.outside {
position: fixed;
background: blue;
top: 0;
height: 65px;
width: 53px;
z-index: 10;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="outside"></div>
<iframe sandbox="allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation"
allow="geolocation" name="v4wj632" src="./ifram1.html" scrolling="no"
style="width: 100%; border: none; position: relative; height: 1148px; top: 0px; left: 0px; display: block;"></iframe>
</div>
</body>
</html>
Iframe src page (ifram1.html):
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
h1 {
border: 1px solid red;
position: fixed;
top: 0;
width: 100%;
text-align: center;
z-index: 11;
}
div.para {
clear: both;
margin-top: 100px;
}
</style>
</head>
<body>
<div class="wrapper">
<h1>
Hello
</h1>
<div class="para">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap
into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the
release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap
into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the
release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
</div>
</body>
</html>
The div outside iframe sticks to the top but h1 tag inside i frame