模仿了首页大部分呈现
html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="font/iconfont.css" />
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/index.css" />
<script>
window.onload = function () {
let itemclassify = document.querySelector(".itemclassify");
// console.log(itemclassify.innerHTML);
itemclassify.addEventListener("mouseover", showList);
itemclassify.addEventListener("mouseout", hideList);
function showList(ev) {
if (
ev.target.nodeName == "SPAN" &&
ev.target.nextElementSibling.nodeName == "UL"
) {
//判断触发事件的对象是否为A标签的兄弟标签ul
ev.target.nextElementSibling.style.display = "block";
}
}
function hideList(ev) {
if (
ev.target.nodeName == "SPAN" &&
ev.target.nextElementSibling.nodeName == "UL"
) {
//判断触发事件的对象是否为A标签的兄弟标签ul
ev.target.nextElementSibling.style.display = "none";
}
}
let leftSideBar = document.querySelector(".leftSideBar");
let ht = document.documentElement;
console.log(ht.scrollTop);
document.body.addEventListener("scroll", showMM);
window.addEventListener("load", showMM);
function showMM() {
console.log(document.body.scrollTop);
if (document.body.scrollTop >= 400) {
leftSideBar.style.display = "block";
} else {
leftSideBar.style.display = "none";
}
}
};
</script>
</head>
<body>
<header>
<div class="flexDis flexJContentSb container flexAlignItemsC">
<div>
<span>xx市</span>
<span class="iconfont icon-xiala iconS"></span>
</div>
<div class="flexDis">
<div>
<span>请登入</span>
</div>
<div>
<span>注册</span>
</div>
<div>
<span>签到有礼</span>
</div>
<div>
<span>我的订单</span>
</div>
<div>
<span>我的特卖</span>
<span class="iconfont icon-xiala iconS"></span>
</div>
<div>
<span>会员俱乐部</span>
<span class="iconfont icon-xiala iconS"></span>
</div>
<div>
<span>客户服务</span>
<span class="iconfont icon-xiala iconS"></span>
</div>
<div>
<span class="iconfont icon-shouji"></span>
<span>手机版</span>
</div>
<div>
<span>更多</span>
<span class="iconfont icon-xiala iconS"></span>
</div>
</div>
</div>
</header>
<section class="sectcon1 flexDis container flexAlignItemsC flexJContentSb">
<div><img src="pic/vip_logo.jpg" alt="" /></div>
<div class="flexDis flexJContentSb" style="width: 300px;">
<a href="#">
<span class="iconfont icon-anquan"></span>
<span>100%正品</span>
</a>
<a href="#">
<span class="iconfont icon-smile"></span>
<span>88元免邮</span>
</a>
<a href="#">
<span class="iconfont icon-tianmaoqitiantuihuo"></span>
<span>退换无忧</span>
</a>
</div>
<div>
<div>
<input type="text" value="" name="search" class="search_input" /><a
href="#"
class="search_a"
>
<span class="iconfont icon-sousuo iconse"></span
></a>
</div>
<div
class="hot-search flexDis flexJContentSb"
style="color: gray; font-size: 0.8em;"
>
<span>连衣裙</span>| <span>护肤套装</span>| <span>耐克nike</span>|
<span>女士T恤</span>| <span>女士休闲裤</span>|
<span>手机</span>
</div>
</div>
<div class="spackage">
<span class="iconfont icon-gouwudai gggwdsize"></span>
<span>购物袋</span>
<span class="spackagenum">0</span>
</div>
</section>
<nav class="flexDis container flexJContentSb flexAlignItemsC">
<div class="itemclassify">
<span class="iconfont icon-fenlei"></span>
<span>商品分类</span>
<ul class="itemclassifyList">
<li>女装/男装/内衣</li>
<li>女鞋/男鞋/箱包</li>
<li>运动户外</li>
<li>家电数码</li>
<li>居家用品</li>
<li>母婴童装</li>
<li>手表配饰</li>
</ul>
</div>
<div
class="flexDis flexJContentSb"
style="width: 800px; font-size: 1.2em;"
>
<span>首页</span>
<span>端午特卖</span>
<span>最后疯抢</span>
<span>唯品快抢</span>
<span>女装</span>
<span>母婴</span>
<span>家电</span>
<span>国际</span>
<span>美妆</span>
<span>鞋包</span>
<span>男装</span>
</div>
<div style="font-size: 1.2em;">
<span>更多</span>
<span class="iconfont icon-down"></span>
</div>
</nav>
<section class="lunbotu">
<div class="inner">
<img src="pic/bac3.jpg" alt="" />
<img src="pic/bac2.jpg" alt="" />
<div class="lunboContent flexDis flexJContentSa">
<span>端午特卖 亿元补贴</span>|
<span>阿迪达斯VIP大牌日 全场低至2折</span>|
<span>欧莱雅VIP大牌日 逆时瓶买1享4</span>|
<span>假期宅家攻略</span>
</div>
<div class="before-after flexDis flexJContentSb">
<span class="iconfont icon-zuo"></span>
<span class="iconfont icon-xiangyou"></span>
</div>
</div>
</section>
<div class="rightSideBar">
<ul class="flexDis flexDirV flexJContentFS">
<li class="flexDis flexDirV">
<span class="iconfont icon-sun iconRB"></span>
<span style="width: 16px;">账号</span>
</li>
<li class="flexDis flexDirV">
<span class="iconfont icon-Handshake iconRB"></span>
<span style="width: 16px;">购物袋</span>
</li>
<li>
<span class="iconfont icon-smile iconRB"> </span>
</li>
<li>
<span class="iconfont icon-smile iconRB"></span>
</li>
<li>
<span class="iconfont icon-smile iconRB"></span>
</li>
<li>
<span class="iconfont icon-smile iconRB"></span>
</li>
</ul>
</div>
<div class="leftSideBar">
<ul class="flexDis flexDirV">
<li style="background-color: rgb(241,1,128); border-radius: 2px;">
精选
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>女装</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>鞋包</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>男装</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>运动</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>女装</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>鞋包</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>男装</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>运动</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>男装</span>
</li>
<li>
<span class="iconfont icon-smile"></span>
<span>运动</span>
</li>
</ul>
</div>
<section class="container" style="margin-top: 100px; margin-bottom: 20px;">
<img src="pic/banner1.jpg" alt="" />
</section>
<section class="container" style="width: 100%;">
<div style="text-align: center; margin: 20px;">
<img src="pic/banner2.jpg" alt="" />
</div>
<div class="flexDis flexJContentC">
<img src="pic/banner3.jpg" alt="" />
<img src="pic/banner4.jpg" alt="" />
<img src="pic/banner5.jpg" alt="" />
</div>
</section>
<footer class="container footerBorder" style="margin-top: 50px;padd">
<div class="flexDis flexJContentSa">
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
<div class="flexDis flexDirV">
<span class="circle">
<span class="iconfont icon-anquan circleSize1"></span>
</span>
<span style="color: gray; padding: 5px;" >全球领先</span>
</div>
</div>
<div class="flexDis flexJContentSe flexAlignItemsC" style="font-size: 10px; margin-top: 20px;">
<div class="rightBorder">
<span>服务保障</span>
<ul>
<li><a href="">正品保证</a></li>
<li><a href="">7天无理由放心退</a></li>
<li><a href="">7x15小时客户服务</a></li>
<li><a href="">7天无理由随心换</a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</div>
<div class="rightBorder">
<span>服务保障</span>
<ul>
<li><a href="">正品保证</a></li>
<li><a href="">7天无理由放心退</a></li>
<li><a href="">7x15小时客户服务</a></li>
<li><a href="">7天无理由随心换</a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</div>
<div class="rightBorder">
<span>服务保障</span>
<ul>
<li><a href="">正品保证</a></li>
<li><a href="">7天无理由放心退</a></li>
<li><a href="">7x15小时客户服务</a></li>
<li><a href="">7天无理由随心换</a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</div>
<div class="rightBorder">
<span>服务保障</span>
<ul>
<li><a href="">正品保证</a></li>
<li><a href="">7天无理由放心退</a></li>
<li><a href="">7x15小时客户服务</a></li>
<li><a href="">7天无理由随心换</a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</div>
<div class="rightBorder">
<span>服务保障</span>
<ul>
<li><a href="">正品保证</a></li>
<li><a href="">7天无理由放心退</a></li>
<li><a href="">7x15小时客户服务</a></li>
<li><a href="">7天无理由随心换</a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</div>
<div class="flexDis flexDirV flexAlignItemsC">
<span>唯品会APP二维码</span>
<img src="pic/二维码.JPG" alt="">
<span>下载唯品会移动APP</span>
</div>
</div>
<div >
<div class="flexDis flexJContentC about" >
<span>关于我们</span>|
<span>About Us</span>|
<span>Investor Relations</span>|
<span>媒体报道</span>|
<span>品牌招商</span>|
<span>隐私条款</span>|
<span>唯品诚聘</span>|
<span>唯品卡</span>|
<span>联系我们</span>
</div >
<div class="relativeItem">
<p>Copyright © 2008-2020 vip.com,All Rights Reserved 使用本网站即表示接受 唯品会用户协议。版权所有 广州唯品会电子商务有限公司</p>
<p>粤公网安备 44010302111111号 粤ICP备08114786号 增值业务经营许可证:粤B2-20170777 网络文化经营许可证:粤网文〔2018〕5030-1743号</p>
<p>经营主体证照 风险监测信息 互联网药品信息服务资格证书:(粤)-经营性-2018-0271 网络食品交易第三方平台备案凭证:粤B2-20170777 医疗器械网络交易服务第三方平台备案</p>
<p>凭证:(粤)网械平台备字[2019]第00001号</p>
</div>
</div>
</footer>
</body>
</html>
CSS代码(首页部分)
header > div > div:nth-child(2) > div {
/* border: 1px solid green; */
padding: 0 10px;
}
/* 设置头部背景和字体 */
header {
height: 30px;
background-color: lightgray;
}
header > div {
/* background-color: lightgray; */
height: 100%;
}
/* 设置搜索框的边框颜色,以及其后图标的背景色 */
.search_input {
/* background-color: tomato; */
border: 1px solid tomato;
/* display: inline-block; */
height: 45px;
width: 400px;
margin: 0;
font-size: 25px;
}
.search_a {
display: inline-block;
border: rgb(241,1,128);
color: white;
background-color:rgb(241,1,128);
height: 45px;
width: 50px;
text-align: center;
vertical-align: top;
margin: 0;
}
.iconse {
line-height: 45px;
font-size: 25px;
}
/* 设置搜索区域 */
.sectcon1 {
height: 150px;
/* border: 1px solid red; */
}
/* 设置购物袋 */
.spackage {
/* margin-left: -100px; */
border: 1px solid lightgray;
height: 45px;
line-height: 40px;
width: 120px;
text-align: center;
border-radius: 5px;
background-color: lightsteelblue;
margin-bottom: 20px;
}
.gggwdsize {
font-size: 25px; */
}
.spackagenum{
display: inline-block;
background-color:rgb(241,1,128);
height: 20px;
width: 30px;
border-radius: 5px;
color: white;
vertical-align: text-bottom;
font-size: 20px;
line-height: 20px;
}
/* 商品分类样式设置 */
.itemclassify{
background-color: rgb(241,1,128);
padding: 10px 30px;
color: white;
font-size: large;
position: relative;
}
/* 商品分类下拉列表 */
.itemclassifyList{
position: absolute;
top: 40px;
left: 0;
z-index: 1;
display: none;
;
width: 100%;
background-color: rgb(241,1,128);
/* display: none; */
}
.itemclassifyList >li{
text-align: center;
height: 50px;
font-size: 15px;
line-height: 50px;
}
/* 轮播途背景设置 */
.lunbotu{
background-image: url("pic/bac1.jpg");
height: 400px;
width: 100%;
border: 1px solid white;
margin: 20px;
background-color: lightblue;
background-repeat: no-repeat;
background-size: cover;
}
/* 轮播图内框设置 ,开启相对定位*/
.inner{
height: 100%;
width: 75%;
background-color: white;
border-top: 1px solid white;
background-origin: border-box;
margin-left: auto ;
margin-right: auto;
margin-top: 35px;
box-shadow: 0 3px 5px rgba(0,0,0,0.2);
position:relative
}
/* 轮播图片设置,开启绝对定位 */
.inner > img{
display: block;
width: 95%;
height: 88%;
position: absolute;
left: 2.5%;
top: 4%;
}
/* 设置轮播图下方的文字 */
.lunboContent{
width: 100%;
position: absolute;
right: 0;
bottom: 0;
}
.lunboContent > span:nth-child(1){
border-bottom: rgb(241,1,128) solid 3px;
}
.lunboContent > span:hover{
border-bottom: rgb(241,1,128) solid 3px;
}
/* 设置轮播图片按钮 */
.before-after{
position: absolute;
top: 40%;
width: 95%;
left: 2.5%;
}
.before-after > span{
font-size: 20px;
line-height: 50px;
color: lightgrey;
height: 50px;
width: 50px;
background-color: rgba(17, 15, 15, 0.349);
text-align: center;
transition: width 2s;
}
.before-after > span:nth-child(1){
font-weight: bold;
}
.before-after > span:hover{
color: white;
width: 100px;
}
/* 左侧边栏设置 */
.leftSideBar{
display: none;
position: fixed;
left: 5px;
top:200px;
border: 1px solid lightgray;
border-radius: 2px;
box-shadow: 0 5px 5px rgba(0,0,0,0.2);
}
.leftSideBar > ul > li{
text-align: center;
padding: 5px;border-bottom: 1px solid rgb(161, 159, 159);
margin: 10px;
color: gray;
font-size: 13px;
}
/* 右侧边栏设置 */
.rightSideBar{
position: fixed;
height: 100%;
width: 40px;
/* border: 1px solid red; */
/* z-index: 1; */
right: 17px;
top: 0px;
}
/* 设置高度为窗口高度 */
.rightSideBar > ul{
height: 100%;
}
/* */
.rightSideBar > ul > li{
/* border: 1px solid red; */
}
.rightSideBar > ul > li:nth-child(2){
height: 25%;
background-color:red;
color: white;
font-size: 25px;
}
.rightSideBar > ul > li:nth-child(1){
height: 20%;
background-color:black;
color: white;
font-size: 25px;
}
.rightSideBar > ul > li:nth-child(n+3) {
height: 15%;
}
.rightSideBar > ul > li:nth-child(n+3) > span{
display: block;
height: 100%;
line-height: 100%;
color: white;
background-color: black;
text-align: center;
}
/* 设置字体图标 */
.iconRB{
font-size: 25px;
}
/* 页脚设置 */
.circle{
display: inline-block;
height: 70px;
text-align: center;
border-radius: 50%;
width: 70px;
border: rgba(17, 15, 15, 0.349) 1px solid;
}
/* 字体图标外框圆形设置 */
.circleSize1{
font-size: 40px;
color: gray;
line-height: 70px;
}
.rightBorder{
padding-right: 40px;
border-right: 1px solid black;
padding-left: 0px;
}
/* 页脚边框设置 */
.footerBorder{
/* border: 1px solid red; */
box-shadow: 0 5px 5px rgba(17, 15, 15, 0.349);
}
.about{
font-size: 13px;
margin: 5px auto;
background-color: rgb(241,1,128);
color:white;
}
.about >span{
padding: 2px 5px;
}
.relativeItem{
padding: 20px;
}
.relativeItem >p{
margin: 0 auto;
color: gray;
font-size: 13px;
}
css代码(公共部分)
* {
padding: 0;
margin: 0;
box-sizing: border-box;
list-style: none;
}
/* 页面宽高设为浏览器窗口的100%,垂直方向滚动 */
html,
body {
width: 100%;
height: 100%;
overflow-x: hidden;
font-size: 16px;
}
/* 通用容器宽度 */
.container {
width: 1200px;
margin: 0 auto;
/* border: 1px solid red; */
}
/* 清除a标签下划线 */
a {
color: lightslategrey;
text-decoration: none;
}
/* 清除button,img的边框和外轮廓线 */
button,
img {
border: none;
outline: none;
}
/* 启动弹性盒子 */
.flexDis {
display: flex;
}
/* 主轴在垂直方向 */
.flexDirV {
flex-direction: column;
}
.flexJContentFS {
justify-content: flex-start;
}
.flexJContentC {
justify-content: center;
}
/* 弹性盒子主轴剩余空间 */
.flexJContentSb {
justify-content: space-between;
}
.flexJContentSe {
justify-content: space-evenly;
}
.flexJContentSa {
justify-content: space-around;
}
/* 弹性盒子辅助轴对齐方式 */
.flexAlignItemsC {
align-items: center;
}
/* 调整字体图标的颜色和大小 */
.iconS {
color: grey;
font-size: 10px;
}
效果:(动态部分实现分类下拉列表和左边导航栏在滚动条滚到指定位置才出现)