Prevent horizontal scroll on jQuery Mobile

前端 未结 3 1975
臣服心动
臣服心动 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:43

    With jQuery mobile the order of the css files matters. What I had to do is make sure that I included my theme css before the jQuery Mobile css instead of after it like this:

    
    
    
        
        
        
    
        
        
    

    If you look in jQuery Mobile's css, you'll see code to prevent horizontal scrolling:

    body.ui-mobile-viewport, div.ui-mobile-viewport {
        overflow-x: hidden;
    }
    

    You don't even have to add any classes to your body tag. jQuery mobile does it automatically.

提交回复
热议问题