Home >Web Front-end >CSS Tutorial >How Can I Position an Element Fixed Vertically and Absolute Horizontally While Scrolling?
The user sought a solution for a button that remained a set distance from the right edge of a div, regardless of viewport size, while scrolling with the window. This can be achieved using the following strategy:
<div class="inflow"> <div class="positioner"> <!-- May not be needed --> <div class="fixed"></div> </div> </div>
div.inflow { width: 200px; height: 1000px; border: 1px solid blue; float: right; position: relative; margin-right: 100px; } div.fixed { width: 80px; border: 1px solid red; height: 100px; position: fixed; top: 60px; margin-left: 15px; }
The above is the detailed content of How Can I Position an Element Fixed Vertically and Absolute Horizontally While Scrolling?. For more information, please follow other related articles on the PHP Chinese website!