横向滚动
简单的,用css来实现移动端的横向滚动
话不多说,看代码吧
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
<title>test</title>
<style>
body,p { margin:0; padding:0;}
.concent { margin:50px auto; width:100%; max-width:750px; min-width:320px; }
.box { white-space:nowrap; overflow-x:auto; }
.box::-webkit-scrollbar { width:0; height:0; display: none; }
.box div { list-style:none; display:inline-block; width:100px; line-height:30px; margin-right:10px;
background:#ccc; text-align:center; }
.box p { width:100%; height:50px; background:pink; }
.box div:last-child { margin:0; }
</style>
</head>
<body>
<div class="concent">
<div class="box">
<div>
<p></p><b>横向滚动</b></div><div>
<p></p><b>横向滚动</b></div><div>
<p></p><b>横向滚动</b></div><div>
<p></p><b>横向滚动</b></div><div>
<p></p><b>横向滚动</b></div><div>
<p></p><b>横向滚动</b></div>
</div>
</div>
<script>
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
var isUc = u.indexOf('UCBrowser') > -1;
if(isAndroid&&isUc){
$('.box').on('touchstart',function(){
$(document).on('touchmove',function(e){
e.preventDefault();
});
$(document).on('touchend',function(){
$(document).unbind();
});
});
}
</script>
</body>
</html>