日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

菜单点击展开,超过四个则进行向右滑动显示demo

發(fā)布時(shí)間:2024/4/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 菜单点击展开,超过四个则进行向右滑动显示demo 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

<!doctype html>
<html>
<head>
<base href="http://test.qdetong.com/sites/3c2bb1c00f40463d6cc02cb3c3ba5263/">
<meta charset="utf-8">
<title>產(chǎn)品分類demo</title>
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<meta content="telephone=no" name="format-detection">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta property="wb:webmaster" content="c51923015ca19eb1">
<link href="demo.css" rel="stylesheet" type="text/css">
<style>
html {
font-size:62.5%;
}
* {
-webkit-tap-highlight-color: transparent;
-webkit-appearance: none;
}
[data-etControl="content"] {
padding: 8px;
min-height: 400px;
max-width: 323px;
margin: 0 auto
}
[data-etControl="content"] > [data-etControl] {
margin: 10px 0;
}
ul, li {
list-style: none;
padding: 0;
margin: 0;
}
[data-etcontrol="e_style"] [et_role="classifyList"] {
padding: 1em 0;
width: 100%;
}
[data-etcontrol="e_style"] [et_role="classify"] {
position: relative;
width: 100%;
color: #903;
display: block;
}
[data-etcontrol="e_style"] [et_role="classify"] li {
/*float: left;*/
display: inline-block;
position: relative;
padding: 1%;
width: 24%;
text-align: center;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
cursor: pointer;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
[data-etcontrol="e_style"] [et_role="classify"] li a {
display: block;
padding: .375rem 0;
text-decoration: none;
}
[data-etcontrol="e_style"] [et_role="classify"] li [et_role="navIcon"] {
width: 60px!important;
height: 60px!important;
margin: 0 auto!important;
background-size: 50px 50px!important;
display: block!important;
position: relative!important;
}
[data-etcontrol="e_style"] [et_role="classify"] li [et_role="classifyText"] {
color: #999999;
font-size: 1.2rem;
text-decoration: none;
}
[data-etcontrol="e_style"] [et_role="classify"] li[hasChild='child2'] [et_role="classifyText"]{
background:url(http://test.qdetong.com//system/demotest/imore.png) no-repeat right 3px;
}
/*[data-etcontrol="e_style"] [et_role="classify"] li[hasChild='child2'] [et_role="classifyText"]:after{
position: relative;
content:"";
top:10px;
width:0;
height:0;
border-left:5px solid transparent;
border-right:5px solid transparent;
border-top:5px solid #ccc;
}*/

.active [et_role="classifyText"]{

background:url(http://test.qdetong.com//system/demotest/imore.png) no-repeat right -10px !important;
}
[data-etcontrol="e_style"] [et_role="classify"] li [et_role="classifyCon"] {
display: none;
width: 100%;
background: #f3f3f3;
overflow: hidden;
transition: height .1s;
-webkit-transition: height .1s;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyCon"] li {
background: #f3f3f3;
float: left;
display: inline-block;
width: 25%;
margin-top: -4px;
text-align: center;
overflow: hidden;
border-left: 1px solid #ddd;
height: 4rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 1.5rem;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-moz-tap-highlight-color: rgba(0, 0, 0, 0);
}
[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyConDiv"] {
display: none;
}
/*[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyConDiv"] i {
position: relative;
top: -12px;
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid rgb(243, 243, 243);
}
[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyConDiv"]:nth-child(4n+1) i {
left: 10%;
}
[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyConDiv"]:nth-child(4n+2) i {
left: 35%;
}
[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyConDiv"]:nth-child(4n+3) i {
left: 60%;
}
[data-etcontrol="e_style"] [et_role="classifyConBox"] [et_role="classifyConDiv"]:nth-child(4n+4) i {
left: 60%;
}*/
.home10_60 {
background: url(http://www.eyingbao.com/system/styles/iconcolor60/home10_60.png) 45% 45% no-repeat;
background-size: 60px 60px;
}
.pen_60 {
background: url(http://www.eyingbao.com/system/styles/iconcolor60/pen_60.png) 45% 45% no-repeat;
background-size: 60px 60px;
}
.people3_60 {
background: url(http://www.eyingbao.com/system/styles/iconcolor60/people3_60.png) 45% 45% no-repeat;
background-size: 60px 60px;
}
</style>
</head>
<body>
<div data-etControl="et_Page" class="undefined" >
<div id="all_element">
<!--header content begin-->

<!--header content end-->
<div data-etcontrol="content" class="ui-sortable" style="min-height: 486px; height: auto;">
<div data-etcontrol="e_style" attributiveetid="productlist_1435127045114" name="newsMenu">
<div et_role="classifyList">
<ul et_role="classify">
<li hasChild='child2' οnclick="GetMaoUrl('nav1',this)">
<section class="home10_60" et_role="navIcon"></section>
<section et_role="classifyText">產(chǎn)品一</section>
</li>
<li hasChild='child2' οnclick="GetMaoUrl('nav2',this)"> <a href="javascript:void(0)" et_role="classifyValueText">
<section class="pen_60" et_role="navIcon"></section>
<section et_role="classifyText">產(chǎn)品二</section>
</a></li>
<li hasChild='child2' οnclick="GetMaoUrl('nav3',this)"> <a href="javascript:void(0)" et_role="classifyValueText">
<section class="people3_60" et_role="navIcon"></section>
<section et_role="classifyText">產(chǎn)品三</section>
</a></li>
<li> <a href="#" et_role="classifyValueText">
<section class="home10_60" et_role="navIcon"></section>
<section et_role="classifyText">產(chǎn)品四</section>
</a></li>
<li> <a href="#" et_role="classifyValueText">
<section class="home10_60" et_role="navIcon"></section>
<section et_role="classifyText">產(chǎn)品5</section>
</a></li>
<li hasChild='child2' οnclick="GetMaoUrl('nav4',this)"> <a href="javascript:void(0)" et_role="classifyValueText">
<section class="home10_60" et_role="navIcon"></section>
<section et_role="classifyText">產(chǎn)品6</section>
</a></li>
</ul>
</div>
<div et_role="classifyConBox" >
<div et_role="classifyConDiv" id="nav1" class=""> <i></i>
<ul et_role="classifyCon">
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">分類1</a>
<li><a et_role="classifyConValueText">&nbsp;</a>
</ul>
</div>
<div et_role="classifyConDiv" id="nav2"> <i></i>
<ul et_role="classifyCon">
<li><a et_role="classifyConValueText">分類2</a>
<li><a et_role="classifyConValueText">分類2</a>
<li><a et_role="classifyConValueText">分類2</a>
<li><a et_role="classifyConValueText">&nbsp;</a>
</ul>
</div>
<div et_role="classifyConDiv" id="nav3"> <i></i>
<ul et_role="classifyCon">
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類3</a>
<li><a et_role="classifyConValueText">分類33333</a>
<li><a et_role="classifyConValueText">&nbsp;</a>
</ul>
</div>
<div et_role="classifyConDiv" id="nav4"> <i></i>
<ul et_role="classifyCon">
<li><a et_role="classifyConValueText">分類6</a>
<li><a et_role="classifyConValueText">&nbsp;</a>
<li><a et_role="classifyConValueText">&nbsp;</a>
<li><a et_role="classifyConValueText">&nbsp;</a>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="http://J.bjyyb.net/jq.js"></script>
<script>
var touchStart = window.navigator.msPointerEnabled ? "MSPointerDown" : "touchstart";
var touchMove = window.navigator.msPointerEnabled ? "MSPointerMove" : "touchmove";
var touchEnd = window.navigator.msPointerEnabled ? "MSPointerUp" : "touchend";
var startPosition = 0;
var endPosition = 0;
var movePosition;
var ulLocation = 0;

var nObj=$("[data-etControl='e_style']").find("[et_role='classify']");
var liNum = nObj.find("li").length+1;
if(nObj.find("li").length < 5)
{
nObj.find("li").css("width",liNum+"%");
}
else
{
var liWidth =parseInt($("[data-etControl='e_style']").parent().width()/4);
console.log(liWidth,liNum)
nObj.find("li").css("width",liWidth+"px").parent().css("width",liWidth*liNum+"px");
document.querySelector("[data-etControl='e_style']").addEventListener(touchStart,touchStarts,false);
document.querySelector("[data-etControl='e_style']").addEventListener(touchEnd,touchEnds,false);
}
function locationUl(val){ //動(dòng)畫賦值
$("[data-etControl='e_style'] [et_role='classify']").css({
"transform":"translateX("+val+"px)",
"-ms-transform":"translateX("+val+"px)",
"-moz-transform":"translateX("+val+"px)",
"-webkit-transform":"translateX("+val+"px)"
});
}
function touchStarts(event){
event.pageX ? startPosition = event.pageX : startPosition = event.changedTouches[0].pageX;
movePosition = startPosition;
transitionTime(0);
document.querySelector("[data-etControl='e_style']").addEventListener(touchMove,touchMoves,false);
$("[et_role='classifyConDiv']").hide();
}
function touchMoves(event){
event.preventDefault();
var offsetPosition;
event.pageX ? offsetPosition = event.pageX : offsetPosition = event.changedTouches[0].pageX;
movePosition = offsetPosition - movePosition ;
//console.log("movePosition:",movePosition,offsetPosition)
locationUl(movePosition+getLocation());
movePosition = offsetPosition;
}
function touchEnds(event){
event.pageX ? endPosition = event.pageX: endPosition = event.changedTouches[0].pageX;
getLocation() > 0 && locationUl(0);
transitionTime(.3);
var panelWidth = $("[data-etControl='e_style']").width();
var ulWidthPanel = $("[data-etControl='e_style'] [et_role='classify']").width();
var panelLastPosition = ulWidthPanel-panelWidth;
getLocation() < -panelLastPosition && locationUl(-panelLastPosition);
transitionTime(.3);
}
function getLocation(){ //獲取動(dòng)畫層當(dāng)前位置
//console.log($("[data-etControl='e_style'] [et_role='classify']").css("transform"))
var transform,data;
if($("[data-etControl='e_style'] [et_role='classify']").css("transform"))
{
transform = $("[data-etControl='e_style'] [et_role='classify']").css("transform");

}
if($("[data-etControl='e_style'] [et_role='classify']").css("-webkit-transform"))
{
transform = $("[data-etControl='e_style'] [et_role='classify']").css("-webkit-transform");

}
if($("[data-etControl='e_style'] [et_role='classify']").css("-moz-transform"))
{
transform = $("[data-etControl='e_style'] [et_role='classify']").css("-moz-transform");

}
if($("[data-etControl='e_style'] [et_role='classify']").css("-ms-transform"))
{
transform = $("[data-etControl='e_style'] [et_role='classify']").css("-ms-transform");

}
if(transform=="none"){
transform==ulLocation==0;
}else{
data = transform.split(",");
ulLocation = parseInt(data[4]);
}

return ulLocation;
}

function transitionTime(time){
$("[data-etControl='e_style'] [et_role='classify']").css({
"transition":"all "+time+"s",
"-ms-transition":"all "+time+"s",
"-moz-transition":"all "+time+"s",
"-webkit-transition":"all "+time+"s"
})
}


GetMaoUrl = function (maoid,e){
var str=location.href,
strs= new Array(),
navObj=$("#"+maoid);
strs=str.split("#");
location.href = strs[0] + '#' + maoid;

function exspend(){
var navClass=navObj.attr("class");

if(navClass=="exspend"){
navObj.removeClass("exspend").hide();
$(e).removeClass("active");
}else{
$("[haschild='child2']").removeClass("active");
navObj.show().addClass("exspend");
$("[et_role='classifyConDiv']").not("#"+maoid).hide().removeClass("exspend");
$(e).addClass("active");
}
}
exspend();

}

</script>
</body>
</html>

轉(zhuǎn)載于:https://www.cnblogs.com/litterjoan/articles/4610141.html

超強(qiáng)干貨來襲 云風(fēng)專訪:近40年碼齡,通宵達(dá)旦的技術(shù)人生

總結(jié)

以上是生活随笔為你收集整理的菜单点击展开,超过四个则进行向右滑动显示demo的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。