I have a button fixed
inside of outer
div. The problem is when I set position: fixed
(to keep the button stay while the page is scrolling) it didn't work properly.
The button still scrolled and moved out of the screen.
here is my code
.rotate {
transform: rotate(30deg);
background: blue;
width: 300px;
height: 300px;
margin: 0 auto;
}
.fixed {
position: fixed;
background: red;
padding: 10px;
color: white;
top: 50px;
}
<div class="rotate">
<button class="fixed"> I am fixed inside a rotated div.</button>
</div>
<!-- <div class="fixed"> I am fixed outside a rotated div.</div> -->
How can I fix it to keep button always display on the screen while scrolling the page?