I want to fix an element with position: fixed in the lower right position for the parent element.
At present, the main site is centered on the main content that contains everything, and there are margins on the left and right.
I want to display a button that jumps to pagetop in the lower right corner of the main page, not in the left and right margins.
body {
background-color: #000;
}
main {
background-color: pink;
height: 100vh;
margin: auto;
position: relative;
width: 85%;
}
a {
position: fixed;
bottom: 0;
right: 0;
}
<body>
<main>
<a href="#">↑</a>
</main>
</body>
I found a related question and tried sticky, but this didn't respond when I set it to right: 0. Because this content is responsive, it was difficult to place it with px designation.