How can I hide an element off the edge of the screen?

前端 未结 7 506
醉话见心
醉话见心 2020-12-05 06:56

I\'ve got a div that I want to position partially off-screen like so:

div{
    position: absolute;
    height: 100px;
    width: 100px;
    right: -50px;
            


        
7条回答
  •  孤街浪徒
    2020-12-05 07:27

    You could add a media query to avoid scrolling at a certain point. So basically take the width of your main container and create a min-width media-query using that.

    @media (min-width: 960px) {
        body {
           overflow-x: hidden;
        }
    }
    

    Should work for modern browsers.

提交回复
热议问题