html - Multiple layers of absolute positioning -
i creating comment stream layout, has bar in background has position:absolute. comment items placed on top of bar. works fine, people able mention other users in comment. dropdown menu open when typing @ placed behind consecutive comment. dropdown menu using position: absolute whereas comment has position:relative. seems these multiple layers don't work together.
<div class="timeline"> <div class="comment"> <input placeholder="mention @username"> <div class="mention-dropdown"> <div class="mention">username</div> <div class="mention">username</div> <div class="mention">username</div> <div class="mention">username</div> <div class="mention">username</div> </div> </div> <div class="comment"> comment text </div> <div class="comment"> comment text </div> <div class="comment"> comment text </div> <div class="comment"> comment text </div> <div class="comment"> comment text </div> <div class="comment"> comment text </div> <div class="background"> <div class="bar"></div> </div> <div class="start"> start </div> </div>
my css looks this:
.timeline { .comment { input { width: 100%; } z-index: 10; width: 300px; border: 1px solid gray; border-radius: 5px; background-color: rgb(102, 255, 255); padding: 10px; margin: auto; margin-bottom: 15px; position: relative; .mention-dropdown { width: 100%; position: absolute; background-color: gray; left: 0; z-index: 20; } } .background { height: 100%; width: 100%; position: absolute; height: 100%; width: 100%; top: 0; .bar { top: 0; width: 0px; height: 100%; border: blue solid 2px; position: absolute; left: calc(50% - 3px); } } .start { left: calc(50% - 3px); position: absolute; bottom: 0; background-color: white; } }
i recreated problem in code pen: https://codepen.io/timolemow/pen/eekvln
any appreciated! thank you.
you have remove position relative on div.comment , add on first.
.timeline .comment-wrapper { position:relative; }
wiki
Comments
Post a Comment