how2j.cn


9分7秒
本视频采用html5方式播放,如无法正常播放,请将浏览器升级至最新版本,推荐火狐,chrome,360浏览器 如果装有迅雷,播放视频呈现直接下载状态,请调整 迅雷系统设置-基本设置-启动-监视全部浏览器 (去掉这个选项)

步骤 1 : 效果   
步骤 2 : 布局   
步骤 3 : 纯html   
步骤 4 : 加上样式   
步骤 5 : 样式讲解   
步骤 6 : 再整合在一起   

步骤 1 :

效果

"); window.frames["iframe_show3185"].document.write(decodeHtml($("textarea#stepcodeTextarea3185").val())); window.frames["iframe_show3185"].document.close(); $(window.frames["iframe_show3185"]).load(function(){ $("#iframe_show3185").height($("#iframe_show3185").contents().find("body").height()+showittryitheight); }); $("#iframe_show3185").height($("#iframe_show3185").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> </head> <style> div.categoryWithCarousel{ width: 100%; position:relative; } div.categoryWithCarousel div.headbar{ background-color: #DD2727; } div.categoryWithCarousel div.head{ width: 200px; background-color: #C60A0A; height: 36px; line-height: 36px; font-size: 16px; font-weight: bold; color: white; margin-left: 20px; display: inline-block; } div.categoryWithCarousel div.rightMenu{ display: inline-block; } div.categoryWithCarousel div.rightMenu a{ font-size: 16px; color: white; text-decoration:none; } div.categoryWithCarousel div.rightMenu span{ margin: 0px 20px 0px 20px; } div.categoryWithCarousel div.rightMenu img{ height: 30px; } div.carousel-of-product{ height: 510px; width:1024px; margin:0px auto; } img.carouselImage{ height: 510px !important; } div.carouselBackgroundDiv{ width:100%; height:510px; background-color:#E8E8E8; position:absolute; top:36px; z-index:-1; } </style> <div class="categoryWithCarousel"> <div class="headbar"> <div class="head "> <span class="glyphicon glyphicon-th-list" style="margin-left:10px"></span> <span style="margin-left:10px">商品分类</span> </div> <div class="rightMenu"> <span><a href="#nowhere"><img src="http://127.0.0.1/tmall../../../img/site/chaoshi.png"></a></span> <span><a href="#nowhere"><img src="http://127.0.0.1/tmall../../../img/site/guoji.png"></a></span> <span> <a href="#nowhere"> 平板电视 </a></span> <span> <a href="#nowhere"> 电热水器 </a></span> </div> </div> <div data-ride="carousel" class="carousel-of-product carousel slide" id="carousel-of-product"> <!-- Indicators --> <ol class="carousel-indicators"> <li class="active" data-slide-to="0" data-target="#carousel-of-product"></li> <li data-slide-to="1" data-target="#carousel-of-product" class=""></li> <li data-slide-to="2" data-target="#carousel-of-product" class=""></li> <li data-slide-to="3" data-target="#carousel-of-product" class=""></li> </ol> <!-- Wrapper for slides --> <div role="listbox" class="carousel-inner"> <div class="item active"> <img src="http://127.0.0.1/tmall/img/lunbo/1.jpg" class="carousel carouselImage"> </div> <div class="item"> <img src="http://127.0.0.1/tmall/img/lunbo/2.jpg" class="carouselImage"> </div> <div class="item"> <img src="http://127.0.0.1/tmall/img/lunbo/3.jpg" class="carouselImage"> </div> <div class="item"> <img src="http://127.0.0.1/tmall/img/lunbo/4.jpg" class="carouselImage"> </div> </div> </div> <div class="carouselBackgroundDiv"> </div> </div>
"); window.frames["iframe3185"].document.write(decodeHtml(code3185)); window.frames["iframe3185"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3185"]).load(function(){ $("#iframe3185").height($("#iframe3185").contents().find("body").height()+showittryitheight); }); $("#iframe3185").height($("#iframe3185").contents().find("body").height()+showittryitheight); alreadyWriteCode3185 = code3185; $("#rendering3185").hide(); $("#rendered3185").show(); } var tRereshRetry2DemoPanel3185 = setInterval(rereshRetry2DemoPanel3185,1000); var binded3185 = false; $("textarea#stepcodeTextarea3185").keyup(function(){ if(!binded3185){ $(window).bind('beforeunload',function(){ binded3185 = true; return "xxxx"; }); } var newCode = $(this).val() code3185 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3185!=newCode){ // window.frames["iframe3185"].document.write("
"); // window.frames["iframe3185"].document.write(decodeHtml($("textarea#stepcodeTextarea3185").val())); // window.frames["iframe3185"].document.close(); // $(window.frames["iframe3185"]).load(function(){ // $("#iframe3185").height($("#iframe3185").contents().find("body").height()+showittryitheight); // }); // code3185 = newCode; // } }); $(".tryButton3185").click(function(){ $("#tryDiv3185").show(); $("#stepcodeTextarea3185").focus(); $("#stepcodeTextarea3185").height(200); $("#iframe3185").height(0); window.frames["iframe3185"].document.write("
"); window.frames["iframe3185"].document.write(decodeHtml($("textarea#stepcodeTextarea3185").val())); window.frames["iframe3185"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3185"]).load(function(){ $("#iframe3185").height($("#iframe3185").contents().find("body").height()+showittryitheight); }); $("#iframe3185").height($("#iframe3185").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3185.focus(); editor3185.setSize(null, "250"); $("#rendering3185").hide(); $("#rendered3185").hide(); }); var mixedMode = { name: "htmlmixed", scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i, mode: null}, {matches: /(text|application)\/(x-)?vb(a|script)/i, mode: "vbscript"}] }; var editor3185 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3185"), { lineNumbers: true, styleActiveLine: true, matchBrackets: true, mode:"text/html", theme:"eclipse", selectionPointer: true, lineWrapping: true, extraKeys: { "Alt-/": "autocomplete", "Ctrl-F": "findPersistent", "F8": function(cm) { cm.setOption("fullScreen", !cm.getOption("fullScreen")); }, "Esc": function(cm) { if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); } } }); editor3185.on("change",function(doc){ if(!binded3185){ $(window).bind('beforeunload',function(){ binded3185 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3185 = newCode; $("textarea#stepcodeTextarea3185").val(newCode); if(alreadyWriteCode3185!=code3185){ lastModifedTime3185 = new Date().getTime(); $("#rendering3185").show(); $("#rendered3185").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3185 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3185.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3185").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果
步骤 2 :

布局

增值内容,请先登录
步骤 3 :

纯html

增值内容,请先登录
步骤 4 :

加上样式

增值内容,请先登录
步骤 5 :

样式讲解

增值内容,请先登录
步骤 6 :

再整合在一起

增值内容,请先登录


HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。


关于 实践项目-天猫前端-导航和轮播 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 620943819
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: http://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图