Scrolling and css are aligned with "right: 0px"
On the HTML page, if I align a few <div>
with "right: 0px", they all look very pretty as I expect. However, if I shrink my browser window and a horizontal scrollbar appears, when I scroll to the right, I see unexpected white space (instead of the background colors of my <div>
s). Mine seems to be <div>
aligned relative to the visible area of ββthe page. See sample code below:
<html>
<head>
<style>
<!--
#parent {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
background-color: yellow;
}
#child {
position: absolute;
left: 100px;
top: 300px;
width: 1000px;
height: 400px;
background-color: blue;
}
-->
</style>
</head>
<body>
<div id="parent"><div id="child">some text here</div></div>
</body>
</html>
Is there a way to make the "right: 0px" property align the controls to the size of the entire page, not just the viewport?
Thank.
source to share
The problem is the "absolute" position in the parent element as it scrolls for each definition.
If you set the position to "fixed" and the optional scroll attribute overflow, it should look as expected.
#parent {position: fixed;
overflow: scroll;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
background-color: yellow;
}
source to share