how2j.cn


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

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

步骤 1 :

效果

完整的首页产品列表是在 模仿天猫首页 中,每个分类有5种首页推荐产品,一共17种分类。 为了讲解的便利性,只选取了其中的2个分类来分析样式。

如果屏幕分辨率比较小的话,会看到5个产品换行了,这是因为为了演示实际效果,放在了步骤栏里,压缩了宽度。 相同的代码,放在整个页面就不会换行了。
"); window.frames["iframe_show3203"].document.write(decodeHtml($("textarea#stepcodeTextarea3203").val())); window.frames["iframe_show3203"].document.close(); $(window.frames["iframe_show3203"]).load(function(){ $("#iframe_show3203").height($("#iframe_show3203").contents().find("body").height()+showittryitheight); }); $("#iframe_show3203").height($("#iframe_show3203").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.homepageCategoryProducts{ background-color: #F5F5F5; padding: 50px 10px 50px 10px; margin: 10px auto; max-width: 1013px; } div.productItem{ width: 189px; height: 285px; border: 1px solid white; background-color: white; margin: 8px 4px; float: left; cursor: pointer; } div.productItem span.productItemDesc{ font-size: 12px; color: #666666; display: block; padding: 16px; } div.productItem span.productPrice{ font-size: 16px; color: #FF003A; display: block; padding-left: 16px; margin-top: -10px; } div.productItem img{ width: 187px; height: 190px; } div.productItem img:hover{ opacity: 0.7; filter: alpha(opacity = 70); } div.eachHomepageCategoryProducts{ margin: 0px 0px 40px 0px; } a.productItemDescLink{ display: inline-block; height: 66px; text-decoration:none; } span.categoryTitle{ font-size: 16px; margin-left: 30px; color: #646464; font-weight: bold; } div.left-mark{ display: inline-block; height: 20px; vertical-align: top; width: 5px; background-color: #19C8A9; } img.endpng{ display: block; width: 82px; margin: 0 auto; } </style> <div class="homepageCategoryProducts"> <div class="eachHomepageCategoryProducts"> <div class="left-mark"></div> <span class="categoryTitle">太阳镜</span> <br> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/9543.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 好先生同款墨镜孙红雷偏光男士太阳镜韩明星 </span> </a> <span class="productPrice"> 97.50 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/9532.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 陌森太阳眼镜男女2016偏光定制驾驶近视 </span> </a> <span class="productPrice"> 518.70 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/9521.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 帕莎Prsr太阳镜女偏光镜潮范冰冰同款女 </span> </a> <span class="productPrice"> 624.00 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/9510.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 变色眼镜男女款半框太阳镜大框潮流防辐射防 </span> </a> <span class="productPrice"> 170.00 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/9499.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 新款男士偏光太阳镜日夜两用墨镜潮运动开车 </span> </a> <span class="productPrice"> 551.00 </span> </div> <div style="clear:both"></div> </div> <div class="eachHomepageCategoryProducts"> <div class="left-mark"></div> <span class="categoryTitle">安全座椅</span> <br> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/10192.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 新生儿婴儿提篮式安全座椅汽车用车载儿童安 </span> </a> <span class="productPrice"> 882.00 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/10181.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] REEBABY汽车儿童安全座椅ISOFI </span> </a> <span class="productPrice"> 1,344.00 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/10170.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] REEBABY儿童安全座椅9个月-12岁 </span> </a> <span class="productPrice"> 1,216.00 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/10159.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 好孩子汽车儿童安全座椅goodbaby9 </span> </a> <span class="productPrice"> 1,199.40 </span> </div> <div class="productItem"> <a href="#nowhere"><img width="100px" src="http://127.0.0.1/tmall/img/productSingle_middle/10148.jpg"></a> <a href="#nowhere" class="productItemDescLink"> <span class="productItemDesc">[热销] 惠尔顿儿童安全座椅isofix硬接口汽车 </span> </a> <span class="productPrice"> 1,993.60 </span> </div> <div style="clear:both"></div> </div> <img src="http://127.0.0.1/tmall../../../img/site/end.png" class="endpng" id="endpng"> </div>
"); window.frames["iframe3203"].document.write(decodeHtml(code3203)); window.frames["iframe3203"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3203"]).load(function(){ $("#iframe3203").height($("#iframe3203").contents().find("body").height()+showittryitheight); }); $("#iframe3203").height($("#iframe3203").contents().find("body").height()+showittryitheight); alreadyWriteCode3203 = code3203; $("#rendering3203").hide(); $("#rendered3203").show(); } var tRereshRetry2DemoPanel3203 = setInterval(rereshRetry2DemoPanel3203,1000); var binded3203 = false; $("textarea#stepcodeTextarea3203").keyup(function(){ if(!binded3203){ $(window).bind('beforeunload',function(){ binded3203 = true; return "xxxx"; }); } var newCode = $(this).val() code3203 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3203!=newCode){ // window.frames["iframe3203"].document.write("
"); // window.frames["iframe3203"].document.write(decodeHtml($("textarea#stepcodeTextarea3203").val())); // window.frames["iframe3203"].document.close(); // $(window.frames["iframe3203"]).load(function(){ // $("#iframe3203").height($("#iframe3203").contents().find("body").height()+showittryitheight); // }); // code3203 = newCode; // } }); $(".tryButton3203").click(function(){ $("#tryDiv3203").show(); $("#stepcodeTextarea3203").focus(); $("#stepcodeTextarea3203").height(200); $("#iframe3203").height(0); window.frames["iframe3203"].document.write("
"); window.frames["iframe3203"].document.write(decodeHtml($("textarea#stepcodeTextarea3203").val())); window.frames["iframe3203"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3203"]).load(function(){ $("#iframe3203").height($("#iframe3203").contents().find("body").height()+showittryitheight); }); $("#iframe3203").height($("#iframe3203").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3203.focus(); editor3203.setSize(null, "250"); $("#rendering3203").hide(); $("#rendered3203").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 editor3203 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3203"), { 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); } } }); editor3203.on("change",function(doc){ if(!binded3203){ $(window).bind('beforeunload',function(){ binded3203 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3203 = newCode; $("textarea#stepcodeTextarea3203").val(newCode); if(alreadyWriteCode3203!=code3203){ lastModifedTime3203 = new Date().getTime(); $("#rendering3203").show(); $("#rendered3203").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3203 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3203.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3203").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

上传截图