I want an element to be positioned as sticky (not fixed) for it be on the screen everytime when I scroll, lets call it menuV, but I also need it to be positioned as absolute so it doesn´t interact with the the div that sits under it, lets call it todo. The "todo" div covers the full width of the screen (100%) and sits under the "menuV".
In the next code, the "menuV" will show as a light blue div and the "todo" div shows as a grey div.
If I set the "menuV" to absolute, it doesn´t stay on the screen when I scroll, and if I set it to sticky, the "todo" div its placed below the "menuV", because it has a width of 100%, so I need a way to set both positions at the same time.
Here you can see the code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0;
}
#header {
width: 100%;
height: 200px;
background-color: blueviolet;
border: 6px solid #5b00b5;
padding: 0;
}
#div_padre {
background-color: sandybrown;
width: 100%;
border: 6px solid #a86002;
position: absolute;
}
#menuH {
position: sticky;
top: 0;
height: 50px;
background-color: royalblue;
border: 6px solid #0000f5;
}
#menuV {
width: 50px;
height: 92vh;
width: 20%;
top: 50px;
position: sticky;
background-color: #00ffe5;
border: 6px solid #0079ad;
float: left;
}
#todo {
width: 100%;
background-color: #454545;
border: 6px solid #000000;
float: left;
}
<div id="header">HEADER</div>
<div id="div_padre">
<div id="menuH"></div>
<div id="menuV"></div>
<div id="todo">
<pre style="margin:0;">
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
asd
</pre>
</div>
</div>
I have been doing some researching and the only thing I found is this, which is really what I need, but for some reason, I cant encapsulate the ids of the elements on the css just like they say in the comments.