Prevent horizontal scroll on jQuery Mobile

前端 未结 3 1971
臣服心动
臣服心动 2021-01-22 16:28

Is there a way to prevent horizontal page scroll on a mobile device preferably with CSS only?

Here\'s an example: http://jsfiddle.net/YfLst/15/

Update:<

3条回答
  •  情歌与酒
    2021-01-22 16:52

    There are different ways to do that:

    You could target mobile devices with a special stylesheet

    
    

    And set the body width to 100% and overflow-x: hidden, or even try to position it absolutely

    body {
      width: 100%;
      overflow-x: hidden;
      position: absolute;
      top: 0;
      left: 0;
    }
    

    in css.

    If by "preventing horizontal scrolling" you mean that your viewport (the area displayed on the mobile screen) is too narrow and should be bigger, you should set the viewport width accordingly in your meta tags

        
    

提交回复
热议问题