商品缩略图和商品详情图都特别大
来源:9-12 前端展示系统开发总结
321121254
2017-12-21
大的简直不能看
写回答
2回答
-
翔仔
2017-12-21
这是我的html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>商品详情</title> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <link rel="shortcut icon" href="/favicon.ico"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css"> <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css"> <link rel="stylesheet" href="../resources/css/frontend/productdetail.css"> </head> <body> <div class="page-group"> <div class="page"> <header class="bar bar-nav"> <a class="button button-link button-nav pull-left" external href="#" onClick="javascript :history.back(-1);" data-transition='slide-out'> <span class="icon icon-left"></span> 返回 </a> <h1 class="title" id="product-name">商品详情</h1> </header> <nav class="bar bar-tab"> <a class="tab-item" href="/o2o/frontend/index" external> <span class="icon icon-home"></span> <span class="tab-label">首页</span> </a> <a class="tab-item" href="#" id="me"> <span class="icon icon-me"></span> <span class="tab-label">我</span> </a> </nav> <div class="content infinite-scroll infinite-scroll-bottom" data-distance="100"> <!-- 这里是页面内容区 --> <div class="shop-detail-dev"> <div class="card"> <div valign="bottom" class="card-header color-white no-border no-padding"> <img class="card-cover" id="product-img" src="" alt="" /> </div> <div class="card-content"> <div class="card-content-inner"> <p class="color-gray"> <span id="product-time">2015/01/15</span> <span class="pull-right" id="product-point"></span> </p> <p id="price" hidden="true"> <span class="color-gray" id="normalPrice"> </span> <span><font color="red" size="4" id="promotionPrice"></font></span> </p> <p id="product-desc"></p> </div> </div> <div class="card-img" id="imgList"> <!-- 商品详情图 --> </div> </div> </div> </div> </div> <div class="panel-overlay"></div> <div class="panel panel-right panel-reveal" id="panel-right-demo"> <div class="content-block"> <p> <a href="/o2o/local/accountbind?usertype=1" class="close-panel">绑定帐号</a> </p> <p> <a href="/o2o/local/changepsw?usertype=1" class="close-panel">修改密码</a> </p> <p> <a href="/o2o/frontend/myrecord" class="close-panel">消费记录</a> </p> <p> <a href="/o2o/frontend/mypoint" class="close-panel">我的积分</a> </p> <p> <a href="/o2o/frontend/pointrecord" class="close-panel">兑换记录</a> </p> <p> <a href="#" usertype="1" class="close-panel" id="log-out">登出系统</a> </p> <!-- Click on link with "close-panel" class will close panel --> </div> </div> </div> <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script> <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script> <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script> <script type='text/javascript' src='../resources/js/common/common.js' charset='utf-8'></script> <script type='text/javascript' src='../resources/js/frontend/productdetail.js' charset='utf-8'></script> <script type='text/javascript' src='../resources/js/local/login.js' charset='utf-8'></script> </body> </html>
这是我的css
.shopdetail-button-div { margin: 0 .3rem; } .shopdetail-button-div > .button { width: 30%; height: 1.5rem; line-height: 1.5rem; display: inline-block; margin: 1%; overflow: hidden; }
这是我的js
$(function() { // 从地址栏的URL里获取productId var productId = getQueryString('productId'); // 获取商品信息的URL var productUrl = '/o2o/frontend/listproductdetailpageinfo?productId=' + productId; // 访问后台获取该商品的信息并渲染 $ .getJSON( productUrl, function(data) { if (data.success) { // 获取商品信息 var product = data.product; // 给商品信息相关HTML控件赋值 // 商品缩略图 $('#product-img').attr('src', getContextPath() + product.imgAddr); // 商品更新时间 $('#product-time').text( new Date(product.lastEditTime) .Format("yyyy-MM-dd")); if (product.point != undefined) { $('#product-point').text( '购买可得' + product.point + '积分'); } // 商品名称 $('#product-name').text(product.productName); // 商品简介 $('#product-desc').text(product.productDesc); // 商品价格展示逻辑,主要判断原价现价是否为空 ,所有都为空则不显示价格栏目 if (product.normalPrice != undefined && product.promotionPrice != undefined) { // 如果现价和原价都不为空则都展示,并且给原价加个删除符号 $('#price').show(); $('#normalPrice').html( '<del>' + '¥' + product.normalPrice + '</del>'); $('#promotionPrice').text( '¥' + product.promotionPrice); } else if (product.normalPrice != undefined && product.promotionPrice == undefined) { // 如果原价不为空而现价为空则只展示原价 $('#price').show(); $('#promotionPrice').text( '¥' + product.normalPrice); } else if (product.normalPrice == undefined && product.promotionPrice != undefined) { // 如果现价不为空而原价为空则只展示现价 $('#promotionPrice').text( '¥' + product.promotionPrice); } var imgListHtml = ''; // 遍历商品详情图列表,并生成批量img标签 product.productImgList.map(function(item, index) { imgListHtml += '<div> <img src="' + getContextPath() + item.imgAddr + '" width="100%" /></div>'; }); // 2.0新增 if (data.needQRCode) { // 若顾客已登录,则生成购买商品的二维码供商家扫描 imgListHtml += '<div> <img src="/o2o/frontend/generateqrcode4product?productId=' + product.productId + '" width="100%"/></div>'; } $('#imgList').html(imgListHtml); } }); // 点击后打开右侧栏 $('#me').click(function() { $.openPanel('#panel-right-demo'); }); $.init(); });
烦请同学对照一下,或者对照一下视频,别的同学都没有这样的问题呢,肯定是跟样式有关的
00 -
翔仔
2017-12-21
那是同学没有引入css的原因 请在html里<head>间引入
<link rel="stylesheet"
href="../resources/css/frontend/productdetail.css">
022017-12-21
相似问题