部分定位设置还有位置关系非最优化写法有待改进
页眉部分CSS代码
*{/*去除白色边框距离*/ margin: 0; padding: 0;}body{/*设置body样式*/ font-size: 14px; background-color: #F5F5F5;}.header{/*设置header标签的位置*/ margin: 25px auto; width: 1200px; margin-bottom: 20px;}/*页眉logo图*/.header .logo{/*设置logo图片还有内容分类标签对齐*/ float: left; position: relative;}/*内容分类菜单*/.header .menu{/*设置logo图片还有内容分类标签对齐*/ float: left; position: relative; margin-top: 12px;/*调整内容分类标签位置*/ margin-left: 20px; }.header .menu ul{/*设置header标签下的menu标签下的ul列表不显示*/ display: none; list-style:none;/*消除列表前面点的样式*/ width: 80px;/*不设置影响不会太大*/ position: absolute;/*设置绝对定位 破坏文档流 是得当列表显示是列表不会吧图片挤下去*/ opacity: 0.5;/*设置下拉弹出列表的透明度*/ background: white;/*背景色*/}.header .menu ul li{ font-weight: bold; margin-top: 20px; text-align: center; padding-bottom: 10px;}.header .menu .menu_title a{ text-decoration: none; /*删除a标签内原有文本的下划线*/}.header .menu .menu_title{ border-bottom: 1px solid rgba(0,0,0,.2); /*设置内容分类标签的下边框线*/ padding-bottom: 20px; /*设置内容下边框线的距离*/ width:80px; /*设置边框宽度控制下边框线的长度*/ text-align: center; /*使下边框先和文本居中显示 更加美观*/}.header .auth{ float: right;/*浮动使得注册登录选项右边排放*/}.header .auth ul li a{ text-decoration: none;}.header .auth ul li{ float: left;/*浮动使得并行*/ margin-right: 70px; margin-top: 12px;/*调整位置 为了美观*/ list-style:none; /*删除序号标点*/}
主体内容部分CSS代码
/*主图片部分*/.content{ width:1200px;/*设置图片盒子宽度*/ margin: 25px auto;/*设置位置和上面的盒子位子设置相同*/}.content .banner .banner_img{ margin-top: 20px;/*调整图片和页眉的距离*/}.content .goods{ margin-top: 10px;}.content .goods ul{/*设置列表长度之后等于并排显示列表的综合*/ width: 1280px;}.content .goods ul li{ width: 360px;/*设置盒子宽度*/ float: left;/*浮动并排*/ margin:0 60px 60px 0;/*361*3+40*3=1203>1200 并排的第三个li会被挤下去*/ /*每个li的边框右边空开60px的距离*/ list-style:none; background-color: white; -webkit-box-shadow: 0 0 5px 3px #ccc; /*水平阴影,垂直阴影,阴影渐变程度,阴影尺寸,阴影颜色*/ -moz-box-shadow: 0 0 5px 3px #ccc; box-shadow: 0 0 5px 3px #ccc;}h1{ color: red; margin-top: 15px; margin-bottom: 20px;}.goods .info{ line-height: 25px; width: 300px;/*给商品说明区域添加宽度*/ margin-left: 30px;/*设置商品区域和banner区域相隔的间距为了美观*/}/*商品说明下的部分*/.goods .info .img-btn{ width: 300px;/*给商品价格部分设置宽度*/ margin-top: 10px;/*给价格设置与说明之间的距离*/ font-size: 20px; color: red; font-weight: bold;/*给价格字体加粗显示*/}.goods .info .img-btn .price{ float:left; /*使价格靠左浮动*/}/*购物车设置*/.goods .info .img-btn .btn{ width: 50px;/*给购物车外div边框设置尺寸*/ height: 40px; background-color: red;/*个购物车设置背景色使其明显显示*/ text-align: center;/*使购物车设置居中显示*/ border-radius: 5px;/*设置圆角*/ float: right;/*浮动想右*/ margin-bottom: 20px;/*包裹购物车的div向下边距20px*/}.goods .info .img-btn .cart img{ width: 26px;/*设置购物车的大小*/ height: 22px; margin-top: 10px;/*设置购物车在div的位置*/}/*翻页部分设置*/.fanye{ width: 1200px; height: 60px; line-height: 60px; margin: 0 auto; margin-top: 30px; margin-bottom: 30px; overflow: hidden;}.fanye ul{ list-style:none;/*删除列表前面的点*/ width: 600px; margin:0 auto; padding-left: 40px;}.fanye ul li{ float: left; /*设置浮动使得li标签并排*/ margin-left:30px; /*调整分页标签之间的间距*/}.fanye ul li a{ text-decoration: none;/*删除a标签下的下划线*/}.page{ border-radius: 50%; background: #c5c5c5; padding: 3px 9px;}
页尾部分CSS代码
/*footer部分*/.footer{ width: 1200px; margin: 0 auto; border-top: 1px solid #ccc; /*因为尝试hr标签没用所以尝试设置上边框*/ position: relative;}.fuhao{ margin-left: 440px;/*将特殊符号调整位置*/ position: absolute;}.fuhao p{ float:left; /*设置浮动并排显示*/ margin-top: 30px;/*设置特殊符号的上边距*/}.hongse{ color: red;}