发表于: 2023-01-08 18:52:45

0 168




一个css页面练习

<!DOCTYPE html>
<html lang="zh-CN">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <title>品优购商城-综合网购首选-正品低价、品质保障、配送及时、轻松购物!
   </title>
   <!-- 网站说明 -->
   <meta name="description"
       content="品优购商城-专业的综合网上购物商城,销售家电、数码通讯、电脑、家居百货、服装服饰、母婴、图书、食品等数万个品牌优质商品.便捷、诚信的服务,为您提供愉悦的网上购物体验!" />
   <!-- 关键字 -->
   <meta name="keywords" content="网上购物,网上商城,手机,笔记本,电脑,MP3,CD,VCD,DV,相机,数码,配件,手表,存储卡,京东" />

   <!-- 引入favicon图标 -->
   <link rel="shortcut icon" href="favicon.ico" />
   <!-- 引入我们初始化样式文件 -->
   <link rel="stylesheet" href="css/base.css">
   <!-- 引入我们公共的样式文件 -->
   <link rel="stylesheet" href="css/common.css">
   <!-- 引入我们index.css文件  -->
   <link rel="stylesheet" href="css/index.css">
</head>

<body>
   <!-- 快捷导航模块 start -->
   <section class="shortcut">
       <div class="w">
           <div class="fl">
               <ul>
                   <li>品优购欢迎您!&nbsp;</li>
                   <li>
                       <a href="#">请登录</a> &nbsp; <a href="register.html" class="style_red">免费注册</a>
                   </li>
               </ul>
           </div>
           <div class="fr">
               <ul>
                   <li>我的订单</li>
                   <li></li>
                   <li class="arrow-icon">我的品优购</li>
                   <li></li>
                   <li>品优购会员</li>
                   <li></li>
                   <li>企业采购</li>
                   <li></li>
                   <li class="arrow-icon">关注品优购</li>
                   <li></li>
                   <li class="arrow-icon">客户服务</li>
                   <li></li>
                   <li class="arrow-icon">网站导航</li>
               </ul>
           </div>
       </div>
   </section>
   <!-- 快捷导航模块 end -->
   <!-- header头部模块制作 start -->
   <header class="header w">
       <!-- logo模块 -->
       <div class="logo">
           <h1>
               <a href="index.html" title="品优购商城">品优购商城</a>
           </h1>
       </div>
       <!-- search搜索模块 -->
       <div class="search">
           <input type="search" name="" id="" placeholder="语言开发">
           <button>搜索</button>
       </div>
       <!-- hotwords模块制作 -->
       <div class="hotwords">
           <a href="#" class="style_red">优惠购首发</a>
           <a href="#">亿元优惠</a>
           <a href="#">9.9元团购</a>
           <a href="#">美满9930</a>
           <a href="#">办公用品</a>
           <a href="#">电脑</a>
           <a href="#">通信</a>
       </div>
       <!-- 购物车模块 -->
       <div class="shopcar">
           我的购物车
           <i class="count">8</i>
       </div>
   </header>
   <!-- header头部模块制作 end -->
   <!-- nav模块制作 start -->
   <nav class="nav">
       <div class="w">
           <div class="dropdown">
               <div class="dt">全部商品分类</div>
               <div class="dd">
                   <ul>
                       <li><a href="#">家用电器</a> </li>
                       <li><a href="list.html">手机</a><a href="#">数码</a><a href="#">通信</a> </li>
                       <li><a href="#">电脑、办公</a> </li>
                       <li><a href="#">家居、家具、家装、厨具</a> </li>
                       <li><a href="#">男装、女装、童装、内衣</a> </li>
                       <li><a href="#">个户化妆、清洁用品、宠物</a> </li>
                       <li><a href="#">鞋靴、箱包、珠宝、奢侈品</a> </li>
                       <li><a href="#">运动户外、钟表</a> </li>
                       <li><a href="#">汽车、汽车用品</a> </li>
                       <li><a href="#">母婴、玩具乐器</a> </li>
                       <li><a href="#">食品、酒类、生鲜、特产</a> </li>
                       <li><a href="#">医药保健</a> </li>
                       <li><a href="#">图书、音像、电子书</a> </li>
                       <li><a href="#">彩票、旅行、充值、票务</a> </li>
                       <li><a href="#">理财、众筹、白条、保险</a> </li>

                   </ul>
               </div>
           </div>
           <div class="navitems">
               <ul>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
                   <li><a href="#">服装城</a></li>
               </ul>
           </div>
       </div>

   </nav>

</body>

</html>

css代码:

/* 声明字体图标 这里一定要注意路径的变化 */
@font-face {
font-family: 'icomoon';
   src: url('../fonts/icomoon.eot?tomleg');
   src: url('../fonts/icomoon.eot?tomleg#iefix') format('embedded-opentype'),
     url('../fonts/icomoon.ttf?tomleg') format('truetype'),
     url('../fonts/icomoon.woff?tomleg') format('woff'),
     url('../fonts/icomoon.svg?tomleg#icomoon') format('svg');
   font-weight: normal;
   font-style: normal;
   font-display: block;
 }
/* 版心 */
.w {
width: 1200px;
   margin: 0 auto;
}
.fl {
float: left;
}
.fr {
float: right;
}
.style_red {
color: #c81623;
}
/* 快捷导航模块 */
.shortcut {
height: 31px;
   line-height: 31px;
   background-color: #f1f1f1;
}
.shortcut ul li {
float: left;
}
/* 选择所有的偶数的小li */
.shortcut .fr ul li:nth-child(even) {
width: 1px;
   height: 12px;
   background-color: #666;
   margin: 9px 15px 0;
}
.arrow-icon::after {
content: '\e91e';
   font-family: 'icomoon';
   margin-left: 6px;
}
/* header 头部制作 */
.header {
position: relative;
   height: 105px;

}
.logo {
position: absolute;
   top: 25px;
   width: 171px;
   height: 61px;
   
}
.logo a {
display: block;
   width: 171px;
   height: 61px;
   background: url(../images/logo.png) no-repeat;
   /* font-size: 0;京东的做法*/
   /* 淘宝的做法让文字隐藏 */
   text-indent: -9999px;
   overflow: hidden;
}
.search {
position: absolute;
   left: 346px;
   top: 25px;
   width: 538px;
   height: 36px;
   border: 2px solid #b1191a;
}
.search input {
float: left;
   width: 454px;
   height: 32px;
   padding-left: 10px;
}
.search button {
float: left;
   width: 80px;
   height: 32px;
   background-color: #b1191a;
   font-size: 16px;
   color: #fff;
}
.hotwords {
position: absolute;
   top: 66px;
   left: 346px;
}
.hotwords a {
margin: 0 10px;
}
.shopcar {
position: absolute;
   right: 60px;
   top: 25px;
   width: 140px;
   height: 35px;
   line-height: 35px;
   text-align: center;
   border: 1px solid #dfdfdf;
   background-color: #f7f7f7;
}
.shopcar::before {
content: '\e93a';
   font-family: 'icomoon';
   margin-right: 5px;
   color: #b1191a;
}
.shopcar::after {
content: '\e920';
   font-family: 'icomoon';
   margin-left: 10px;
}
.count {
position: absolute;
   top: -5px;
   left: 105px;
   height: 14px;
   line-height: 14px;
   color: #fff;
   background-color: #e60012;
   padding: 0 5px;
   border-radius: 7px 7px 7px 0;
}
/* nav模块制作 */
.nav {
height: 47px;
   border-bottom: 2px solid #b1191a;
}
.nav .dropdown {
float: left;
   width: 210px;
   height: 45px;
   background-color: #b1191a;
}
.nav .navitems {
float: left;
}
.dropdown .dt {
width: 100%;
   height: 100%;
   color: #fff;
   text-align: center;
   line-height: 45px;
   font-size: 16px;
}
.dropdown .dd {
/* display: none; */
   width: 210px;
   height: 465px;
   background-color: #c81623;
   margin-top: 2px;
}
.dropdown .dd ul li {
position: relative;
   height: 31px;
   line-height: 31px;
   margin-left: 2px;
   padding-left: 10px;
}
.dropdown .dd ul li:hover {
background-color: #fff;
}
.dropdown .dd ul li::after {
position: absolute;
   top: 1px;
   right: 10px;
   color: #fff;
   font-family: 'icomoon';
   content: '\e920';
   font-size: 14px;
}
.dropdown .dd ul li a {
font-size: 14px;
   color: #fff;
}
.dropdown .dd ul li:hover a {
color: #c81623;
}
.navitems ul li {
float: left;
}
.navitems ul li a {
display: block;
   height: 45px;
   line-height: 45px;
   font-size: 16px;
   padding: 0 25px;
}



返回列表 返回列表
评论

    分享到