Align div with fixed position on the right side

后端 未结 8 1337
名媛妹妹
名媛妹妹 2021-02-02 08:08

I want to show a div which is always visible even as the user scrolls the page. I have used the CSS position: fixed; for that.

Now I also want

相关标签:
8条回答
  • 2021-02-02 08:39

    Use the 'right' attribute alongside fixed position styling. The value provided acts as an offset from the right of the window boundary.

    Code example:

    .test {
      position: fixed;
      right: 0;
    }
    

    If you need some padding you can set right property with a certain value, for example: right: 10px.

    Note: float property doesn't work for position fixed and absolute

    0 讨论(0)
  • 2021-02-02 08:42

    Just do this. It doesn't affect the horizontal position.

    .test {
     position: fixed;
     left: 0;
     right: 0;
     }
    
    0 讨论(0)
提交回复
热议问题