Centering a fixed element, but scroll it horizontally

前端 未结 3 581
孤独总比滥情好
孤独总比滥情好 2020-12-21 00:36

Having some issues getting this to work. PLEEEEEEASE help.

I would like an element fixed to the top of the viewport, when the user scrolls down the page it remains a

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 01:24

    Ah, interesting question. I don’t think you can achieve that without JavaScript.

    position: fixed means that the element is positioned relative to the viewport. You want that vertically, but you don’t want it horizontally. I don’t think there’s any way to achieve that in CSS.

提交回复
热议问题