Problem:
A user seeks to create a button that maintains a fixed vertical distance from the viewport while also remaining a specific distance from the right edge of a div, regardless of viewport size.
Solution:
Horizontal Positioning:
While "absolute horizontal" positioning is not technically achievable with the provided solution, the goal of maintaining a fixed distance from the div's right edge can be met. By avoiding setting the left or right properties for the horizontally fixed element, the container divs are used to control its horizontal position.
Vertical Positioning:
The element is positioned vertically fixed using the position: fixed property. By setting a top value, the vertical positioning is maintained regardless of the viewport size.
Code Sample:
The following code demonstrates the implementation:
HTML:
CSS:
div.inflow { width: 200px; height: 1000px; border: 1px solid blue; float: right; position: relative; margin-right: 100px; } div.positioner {position: absolute; right: 0;} div.fixed { width: 80px; border: 1px solid red; height: 100px; position: fixed; top: 60px; margin-left: 15px; }
Key Considerations:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3