how2j.cn


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

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

步骤 1 :

效果

因为购物车里面的订单项部分比较复杂,所以先把结算按钮这部分简单的拿出来单独讲解。 后面就可以专注在订单项部分的讲解了
"); window.frames["iframe_show3262"].document.write(decodeHtml($("textarea#stepcodeTextarea3262").val())); window.frames["iframe_show3262"].document.close(); $(window.frames["iframe_show3262"]).load(function(){ $("#iframe_show3262").height($("#iframe_show3262").contents().find("body").height()+showittryitheight); }); $("#iframe_show3262").height($("#iframe_show3262").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> body{ font-size: 12px; font-family: Arial; } div.cartDiv{ max-width: 1013px; margin: 10px auto; color: black; } div.cartTitle button{ background-color: #AAAAAA; border: 1px solid #AAAAAA; color: white; width: 53px; height: 25px; border-radius: 2px; } span.cartTitlePrice{ color: #C40000; font-size: 14px; font-weight: bold; margin-left: 5px; margin-right: 3px; } div.cartFoot{ background-color: #E5E5E5; line-height: 50px; margin: 20px 0px; color: black; padding-left: 20px; } div.cartFoot button{ background-color: #AAAAAA; border: 0px solid #AAAAAA; color: white; width: 120px; height: 50px; font-size: 20px; text-align: center; } img.cartProductItemIfSelected, img.selectAllItem{ cursor: pointer; } span.cartSumNumber{ color: #C40000; font-weight: bold; font-size: 16px; } span.cartSumPrice{ color: #C40000; font-weight: bold; font-size: 20px; } </style> <div class="cartDiv"> <div class="cartTitle pull-right"> <span>已选商品 (不含运费)</span> <span class="cartTitlePrice">¥0.00</span> <button class="createOrderButton" style="background-color: rgb(170, 170, 170);" disabled="disabled">结 算</button> </div> <div style="text-align:center;color:gray;line-height:100px" > 订单项内容,在下个知识点讲解 </div> <div class="cartFoot"> <img src="http://127.0.0.1/tmall../../../img/site/cartNotSelected.png" class="selectAllItem" selectit="false"> <span>全选</span> <!-- <a href="#">删除</a> --> <div class="pull-right"> <span>已选商品 <span class="cartSumNumber">0</span> 件</span> <span>合计 (不含运费): </span> <span class="cartSumPrice">¥0.00</span> <button class="createOrderButton" style="background-color: rgb(170, 170, 170);" disabled="disabled">结 算</button> </div> </div> </div>
"); window.frames["iframe3262"].document.write(decodeHtml(code3262)); window.frames["iframe3262"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3262"]).load(function(){ $("#iframe3262").height($("#iframe3262").contents().find("body").height()+showittryitheight); }); $("#iframe3262").height($("#iframe3262").contents().find("body").height()+showittryitheight); alreadyWriteCode3262 = code3262; $("#rendering3262").hide(); $("#rendered3262").show(); } var tRereshRetry2DemoPanel3262 = setInterval(rereshRetry2DemoPanel3262,1000); var binded3262 = false; $("textarea#stepcodeTextarea3262").keyup(function(){ if(!binded3262){ $(window).bind('beforeunload',function(){ binded3262 = true; return "xxxx"; }); } var newCode = $(this).val() code3262 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3262!=newCode){ // window.frames["iframe3262"].document.write("
"); // window.frames["iframe3262"].document.write(decodeHtml($("textarea#stepcodeTextarea3262").val())); // window.frames["iframe3262"].document.close(); // $(window.frames["iframe3262"]).load(function(){ // $("#iframe3262").height($("#iframe3262").contents().find("body").height()+showittryitheight); // }); // code3262 = newCode; // } }); $(".tryButton3262").click(function(){ $("#tryDiv3262").show(); $("#stepcodeTextarea3262").focus(); $("#stepcodeTextarea3262").height(200); $("#iframe3262").height(0); window.frames["iframe3262"].document.write("
"); window.frames["iframe3262"].document.write(decodeHtml($("textarea#stepcodeTextarea3262").val())); window.frames["iframe3262"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3262"]).load(function(){ $("#iframe3262").height($("#iframe3262").contents().find("body").height()+showittryitheight); }); $("#iframe3262").height($("#iframe3262").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3262.focus(); editor3262.setSize(null, "250"); $("#rendering3262").hide(); $("#rendered3262").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 editor3262 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3262"), { 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); } } }); editor3262.on("change",function(doc){ if(!binded3262){ $(window).bind('beforeunload',function(){ binded3262 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3262 = newCode; $("textarea#stepcodeTextarea3262").val(newCode); if(alreadyWriteCode3262!=code3262){ lastModifedTime3262 = new Date().getTime(); $("#rendering3262").show(); $("#rendered3262").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3262 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3262.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3262").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

上传截图