Position:absolute causes horizontal scrollbar

前端 未结 4 1978
你的背包
你的背包 2020-12-29 02:44

Absolutely positioned (side yellow advertisements) div\'s cause unwanted horizontal scrollbar when window is resized (size decreased) beyond them. Scrollbar should appear on

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 03:10

    I may like to further add, if the same problem is being faced and by using the solution suggested by @Aaron the page seems to not scroll then you can use axis specific version of the "overflow" attribute, as following,

    overflow-x: hidden;
    

    This will only hide the content protruding on the right hand side (or left hand side if website is RTL) and not the vertical content.

    Also to further enhance this method if the protruding content is appearing only at a certain resolution (as in my case), you can use css media query to restrict the behaviour.

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

提交回复
热议问题