/* * @description 这是动态获取浏览器的宽度,然后设置rem * 使用方式:宽度100px写1rem, 宽度520px写5.2rem */ function fnInitScreen() { var html = document.getElementsByTagName("html")[0]; var width = window.innerWidth; var font_size = 0; font_size = (width / 1920) * 100; //1500 设计图比例 html.style.fontSize = font_size + "px"; } fnInitScreen(); /* * @description 监听浏览器窗口的变动 */ window.onresize = function () { fnInitScreen(); }; /* * @description 这是导航菜单鼠标经过、移出时动态添加class的方法 */ $(".navbar-block .nav-option-block").mouseover(function () { $(this).find("> a").addClass("navbar-checked-hover"); var _secondNavWidth = $(this).find('.navbar-second > div').width(); var _thisLeft = $(this).offset().left; $(this).find('.navbar-second > div').css('margin-left', _thisLeft - _secondNavWidth/2 + 78/2); console.log(_secondNavWidth, _thisLeft); }); $(".navbar-block .nav-option-block").mouseleave(function () { $(this).find("> a").removeClass("navbar-checked-hover"); }); /** * @description 点击搜索 展示 搜索input */ $(".search-btn").on("click", function () { $(".search-btn").hide(); $(".search-input").show(); }); /** * @description 点击搜索 展示 搜索input */ //$(".search-btn-submit").on("click", function () { // alert("执行搜索方法"); //}); /** * @description 所有轮播图的切换速度 */ $(".carousel").carousel({ interval: 3000, }); /** * @description 左侧菜单 三级菜单展示效果 */ $(".common-left-menu-list ul li").on("click", function (event) { event.stopPropagation(); $(this).find("> ul").toggle(); $(this).siblings().find("a").removeClass("common-left-minus"); if ($(this).find("> ul").css("display") == "none") { // $(this).find("> a").removeClass("common-left-minus"); // $(this).find("> a .menu-grey").show(); // $(this).find("> a .menu-blue").hide(); } else { // $(this).find("> a").addClass("common-left-minus"); // $(this).find("> a .menu-grey").hide(); // $(this).find("> a .menu-blue").show(); } // $(this).find("> a .glyphicon").toggleClass('glyphicon-minus'); $(this).find("> a span").toggle(); // $(this).find("> a img").toggle(); });