Blogger Information
Blog 19
fans 0
comment 0
visits 10755
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
实战练习-淘宝顶部导航
牙森江
Original
702 people have browsed it

1.淘宝顶部导航
html代码部分

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  8. <title>淘宝</title>
  9. <link rel="stylesheet" href="CSS/style.css">
  10. </head>
  11. <body>
  12. <header>
  13. <div class="h_t_box">
  14. <ul class="h_t_box_l">
  15. <li>
  16. <span>中国大陆</span>
  17. <span class="iconfont">&#xe645;</span>
  18. <div class="hidden_box">
  19. <ul>
  20. <li>全球</li>
  21. <li>中国大陆</li>
  22. <li>中国香港</li>
  23. <li>中国台湾</li>
  24. <li>中国澳门</li>
  25. <li>韩国</li>
  26. <li>马来西亚</li>
  27. <li>澳大利亚</li>
  28. <li>新加坡</li>
  29. <li>新西兰</li>
  30. <li>加拿大</li>
  31. <li>日本</li>
  32. <li>越南</li>
  33. <li>泰国</li>
  34. <li>菲律宾</li>
  35. <li>柬埔寨</li>
  36. </ul>
  37. </div>
  38. </li>
  39. <li>
  40. <a href="#">亲,请登录</a>
  41. <a href="#">免费注册</a>
  42. </li>
  43. <li><a href="#">手机逛淘宝</a></li>
  44. <li><a href="#">网页无障碍</a></li>
  45. </ul>
  46. <ul class="h_t_box_r">
  47. <li>
  48. <span><a href="">我的淘宝</a></span>
  49. <span class="iconfont">&#xe645;</span>
  50. <div class="hidden_box">
  51. <ul>
  52. <li><a href="#">已买到的宝贝</a></li>
  53. <li><a href="#">我的足迹</a></li>
  54. </ul>
  55. </div>
  56. </li>
  57. <li>
  58. <span class="iconfont">&#xe602;</span>
  59. <span>购物车</span>
  60. </li>
  61. <li>
  62. <a href="https://login.taobao.com/member/login.jhtml?from=taobaoindex&f=top&style=&sub=true&redirect_url=https%3A%2F%2Fshoucang.taobao.com%2Fitem_collect_n.htm%3Fspm%3Da21bo.jianhua.1997525053.1.5af911d9eNtAFT">
  63. <span class="iconfont">&#xe603;</span>
  64. <span>收藏夹</span>
  65. </a>
  66. <span class="iconfont">&#xe645;</span>
  67. <div class="hidden_box">
  68. <ul>
  69. <li><a href="">收藏的宝贝</a></li>
  70. <li><a href="">收藏的店铺</a></li>
  71. </ul>
  72. </div>
  73. </li>
  74. <li><a href="https://huodong.taobao.com/wow/tbhome/act/market-list">商品分类</a>
  75. </li>
  76. <li><a href="https://ishop.taobao.com/openshop/tb_open_shop_landing.htm?spm=a21bo.jianhua.1997563209.2.5af911d9YHFk75#/">免费开店</a>
  77. </li>
  78. <li>
  79. <a href="https://loginmyseller.taobao.com/?from=taobaoindex&f=top&style=&sub=true&redirect_url=https%3A%2F%2Fmyseller.taobao.com%2Fhome.htm%2FQnworkbenchHome%2F%3Fspm%3Da21bo.jianhua.1997525073.1.5af911d98ewzLp">
  80. <span>千牛卖家中心</span>
  81. <span class="iconfont">&#xe645;</span>
  82. </a>
  83. <div class="hidden_box">
  84. <ul>
  85. <li>开店入驻</li>
  86. <li>已卖出的宝贝</li>
  87. <li>出售中的宝贝</li>
  88. <li>卖家服务市场</li>
  89. <li>卖家培训中心</li>
  90. <li>体检中心</li>
  91. <li>电商学习中心</li>
  92. </ul>
  93. </div>
  94. </li>
  95. <li>
  96. <a href="https://consumerservice.taobao.com/?spm=a21bo.jianhua.754895749.1.5af911d9E5MeGW">
  97. <span>联系客服</span>
  98. <span class="iconfont">&#xe645;</span>
  99. </a>
  100. <div class="hidden_box">
  101. <ul>
  102. <li>消费者客服</li>
  103. <li>卖家客服</li>
  104. <li>意见反馈</li>
  105. <li>网页版旺旺</li>
  106. </ul>
  107. </div>
  108. </li>
  109. </ul>
  110. </div>
  111. <div class="bar">
  112. <ul class="pic_bar">
  113. <li><a href="https://pages.tmall.com/wow/a/act/tmall/35385/pha?spm=a21bo.jianhua.1112.1.5af911d9T14qXU&wh_bizStageId=8888&pha=true&disableNav=YES&wh_act_nativebar=0"><img src="./images/banner0.png" alt=""></a></li>
  114. <li><a href="#"><img src="./images/banner1.png" alt=""></a></li>
  115. <li><a href="#"><img src="./images/banner2.png" alt=""></a></li>
  116. <li><a href="#"><img src="./images/banner3.png" alt=""></a></li>
  117. <li><a href="#"><img src="./images/banner4.png" alt=""></a></li>
  118. <li><a href="#"><img src="./images/banner5.png" alt=""></a></li>
  119. </ul>
  120. </div>
  121. <div class="banner">
  122. <div class="banner_t">
  123. <div class="banner_l "><a href="https://www.taobao.com/?spm=a21bo.jianhua.201857.1.5af911d9T14qXU"><img src="./images/左侧logo.png" alt=""></a></div>
  124. <!-- banner中间 -->
  125. <div class="banner_c ">
  126. <ul class="banner_c_t">
  127. <li class="banner_c_t_l">
  128. <span>宝贝</span>
  129. <span class="iconfont">&#xe645;</span>
  130. <div class="hidden_box">
  131. <ul>
  132. <li >天猫</li>
  133. <li>店铺</li>
  134. </ul>
  135. </div>
  136. </li>
  137. <li class="banner_c_t_c">零食</li>
  138. <li class="banner_c_t_r">搜索</li>
  139. </ul>
  140. <ul class="banner_c_b">
  141. <li><a href="#">新款连衣裙</a></li>
  142. <li><a href="#">四件套</a></li>
  143. <li><a href="#">潮流T恤</a></li>
  144. <li><a href="#">时尚女鞋</a></li>
  145. <li><a href="#">短裤</a></li>
  146. <li><a href="#">半身裙</a></li>
  147. <li><a href="#">男士外套</a></li>
  148. <li><a href="#">墙纸</a></li>
  149. <li><a href="#">行车记录仪</a></li>
  150. </ul>
  151. </div>
  152. <!-- banner右侧二维码 -->
  153. <div class="banner_r">
  154. <a href="#">
  155. <p>下载淘宝</p>
  156. <img src="./images/二维码.png" alt="">
  157. </a>
  158. </div>
  159. </div>
  160. </div>
  161. </header>
  162. <div class="bg_img">
  163. <div class="bg_img_l"></div>
  164. <div class="bg_img_r"></div>
  165. </div>
  166. <footer>
  167. </footer>
  168. </body>
  169. </html>

CSS代码部分

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. color: #3c3c3c;
  6. list-style: none;
  7. }
  8. @font-face {
  9. font-family: 'iconfont';
  10. src: url('../iconfont/iconfont.woff2') format('woff2'),
  11. url('../iconfont/iconfont.woff') format('woff'),
  12. url('../iconfont/iconfont.ttf') format('truetype');
  13. }
  14. .iconfont {
  15. font-family: "iconfont" !important;
  16. font-size: 16px;
  17. font-style: normal;
  18. -webkit-font-smoothing: antialiased;
  19. -moz-osx-font-smoothing: grayscale;
  20. }
  21. body {
  22. background-color: rgb(198, 225, 167);
  23. }
  24. a {
  25. text-decoration: none;
  26. }
  27. header {
  28. width: 100%;
  29. height: 36px;
  30. background-color:#f5f5f5;
  31. }
  32. /* 顶部导航 */
  33. header .h_t_box {
  34. display: flex;
  35. width: 1190px;
  36. height: 36px;
  37. font-size: 12px;
  38. margin: auto;
  39. place-content: space-between;
  40. }
  41. /* 顶部导航左侧 */
  42. header .h_t_box .h_t_box_l {
  43. display: flex;
  44. width: 391px;
  45. height: 35px;
  46. line-height: 12px;
  47. place-content: space-between;
  48. line-height: 35px;
  49. }
  50. header .h_t_box .h_t_box_l li {
  51. list-style: none;
  52. height: 35px;
  53. padding: 0 5px;
  54. }
  55. header .h_t_box .h_t_box_l>li:nth-of-type(1):hover {
  56. background-color: rgb(255, 255, 255);
  57. }
  58. header .h_t_box .h_t_box_l .hidden_box {
  59. background-color: rgb(255, 255, 255);
  60. position: absolute;
  61. width: 270px;;
  62. height: 290px;
  63. top: 36px;
  64. display: none;
  65. overflow: scroll;
  66. }
  67. header .h_t_box .h_t_box_l .hidden_box ul li:hover {
  68. background-color: #f4f4f4;
  69. cursor: pointer;
  70. }
  71. header .h_t_box .h_t_box_l>li:nth-of-type(1):hover .hidden_box {
  72. display: block;
  73. }
  74. header .h_t_box .h_t_box_l>li:nth-of-type(1) span:nth-of-type(2) {
  75. color: #3c3c3c;
  76. display: inline-block;
  77. line-height: 35px;
  78. transform: scale(0.7);
  79. }
  80. header .h_t_box .h_t_box_l>li:nth-of-type(2) a:nth-of-type(1) {
  81. color: rgb(255, 8, 0);
  82. padding-right: 10px;
  83. }
  84. header .h_t_box .h_t_box_l>li:nth-last-of-type(-n+3) a:hover {
  85. color: rgb(255, 8, 0);
  86. }
  87. /* 顶部导航右侧 */
  88. header .h_t_box .h_t_box_r li {
  89. list-style: none;
  90. /* background-color: rgb(216, 209, 111); */
  91. height: 35px;
  92. }
  93. header .h_t_box .h_t_box_r .iconfont {
  94. color: #3c3c3c;
  95. display: inline-block;
  96. transform: scale(0.7);
  97. }
  98. header .h_t_box .h_t_box_r {
  99. display: flex;
  100. /* background-color: rgb(113, 215, 199); */
  101. width: 554px;
  102. place-content: space-evenly;
  103. line-height: 35px;
  104. }
  105. header .h_t_box .h_t_box_r>li:nth-of-type(1):hover .hidden_box {
  106. display: block;
  107. }
  108. header .h_t_box .h_t_box_r>li:nth-of-type(1):hover {
  109. background-color: rgb(255, 255, 255);
  110. }
  111. header .h_t_box .h_t_box_r li:nth-of-type(1) .hidden_box {
  112. background-color: rgb(255, 255, 255);
  113. position: absolute;
  114. width: 80px;
  115. height: 75px;
  116. top: 36px;
  117. display: none;
  118. background-color: rgb(255, 255, 255);
  119. }
  120. header .h_t_box .h_t_box_r .hidden_box ul li:hover {
  121. background-color: #f4f4f4;
  122. cursor: pointer;
  123. }
  124. header .h_t_box .h_t_box_r>li:nth-of-type(1) span:nth-of-type(1) a:hover {
  125. color: #ff0000;
  126. }
  127. header .h_t_box .h_t_box_r>li:nth-of-type(1) .iconfont {
  128. color: #3c3c3c;
  129. display: inline-block;
  130. transform: scale(0.7);
  131. }
  132. header .h_t_box .h_t_box_r>li:nth-of-type(2) .iconfont {
  133. color: #f47a00;
  134. display: inline-block;
  135. transform: scale(0.6);
  136. }
  137. header .h_t_box .h_t_box_r>li:nth-of-type(2) span:nth-of-type(2):hover {
  138. color: #ff0000;
  139. cursor: pointer;
  140. }
  141. header .h_t_box .h_t_box_r>li:nth-of-type(3):hover {
  142. background-color: rgb(255, 255, 255);
  143. cursor: pointer;
  144. }
  145. header .h_t_box .h_t_box_r>li:nth-of-type(3):hover .hidden_box{
  146. display: block;
  147. }
  148. header .h_t_box .h_t_box_r>li:nth-of-type(3) a span:hover {
  149. color: #ff0000;
  150. }
  151. header .h_t_box .h_t_box_r>li:nth-of-type(3) span:nth-of-type(1){
  152. font-size: 12px
  153. }
  154. header .h_t_box .h_t_box_r li:nth-of-type(3) .hidden_box {
  155. background-color: rgb(255, 255, 255);
  156. position: absolute;
  157. width: 70px;
  158. height: 75px;
  159. top: 36px;
  160. display: none;
  161. }
  162. header .h_t_box .h_t_box_r>li:nth-of-type(4) a:hover {
  163. color: rgb(255, 0, 0);
  164. }
  165. header .h_t_box .h_t_box_r>li:nth-of-type(5) a:hover {
  166. color: rgb(255, 0, 0);
  167. }
  168. header .h_t_box .h_t_box_r>li:nth-of-type(6) a span:nth-of-type(1):hover {
  169. color: rgb(255, 0, 0);
  170. }
  171. header .h_t_box .h_t_box_r li:nth-of-type(6) .hidden_box {
  172. background-color: rgb(255, 255, 255);
  173. position: absolute;
  174. width: 85px;
  175. height: 245px;
  176. top: 36px;
  177. display: none;
  178. }
  179. header .h_t_box .h_t_box_r li:nth-of-type(6):hover .hidden_box {
  180. display: block;
  181. padding-left: 5px;
  182. }
  183. header .h_t_box .h_t_box_r>li:nth-of-type(7) a span:nth-of-type(1):hover {
  184. color: rgb(255, 0, 0);
  185. }
  186. header .h_t_box .h_t_box_r li:nth-of-type(7) .hidden_box {
  187. background-color: rgb(255, 255, 255);
  188. position: absolute;
  189. width: 80px;
  190. height: 200px;
  191. top: 36px;
  192. display: none;
  193. padding-left: 5px;
  194. }
  195. header .h_t_box .h_t_box_r li:nth-of-type(7):hover .hidden_box {
  196. display: block;
  197. }
  198. /* 图片bar */
  199. header .bar {
  200. width: 100%;
  201. height: 100px;
  202. background-color:#ff72B5;
  203. }
  204. header .bar .pic_bar {
  205. display: flex;
  206. width: 1190px;
  207. height: 100px;
  208. margin: auto;
  209. place-content: space-between;
  210. place-items: center;
  211. }
  212. header .bar .pic_bar li:first-of-type {
  213. width: 105px;
  214. height: 100px;
  215. }
  216. header .bar .pic_bar li:first-of-type img {
  217. width: 80px;
  218. height: 80px;
  219. margin: 10px 10px 10px 15px;
  220. }
  221. header .bar .pic_bar li img {
  222. width: 209px;
  223. height: 75px;
  224. border-radius: 20px;
  225. }
  226. /* banner */
  227. .banner{
  228. width: 1190px;
  229. height: 121px;
  230. border-radius: 15px 15px 0px 0px;
  231. margin: 0px auto;
  232. }
  233. .banner .banner_t {
  234. background-color: rgb(255, 255, 255);
  235. width: 100%;
  236. height: 121px;
  237. display: flex;
  238. }
  239. .banner .banner_t .banner_l {
  240. background-color: rgb(255, 255, 255);
  241. width: 190px;
  242. height: 121px;
  243. }
  244. /* banner中间 */
  245. .banner .banner_c {
  246. background-color: rgb(255, 255, 255);
  247. width: 734px;
  248. height: 70px;
  249. margin-top: 33px;
  250. border-radius: 20px;
  251. }
  252. .banner .banner_c_t {
  253. background-color: rgb(255, 255, 255);
  254. width: 738px;
  255. height: 42px;
  256. border: 2px solid #ff5000;
  257. border-radius: 20px;
  258. display: flex;
  259. place-content: space-between;
  260. line-height: 42px;
  261. place-items: center;
  262. }
  263. .banner .banner_c_t .banner_c_t_l {
  264. background-color: rgb(255, 255, 255);
  265. width: 64px;
  266. height: 36px;
  267. border-radius: 25px;
  268. text-align:center;
  269. line-height: 36px;
  270. margin-left: 1px;
  271. cursor: pointer;
  272. }
  273. .banner .banner_c_t .banner_c_t_l span{
  274. color: #333333;
  275. font-size: 14px;
  276. }
  277. .banner .banner_c_t .banner_c_t_l .hidden_box {
  278. margin: 0;
  279. width: 64px;
  280. height: 60px;
  281. background-color: #fff;
  282. display: none;
  283. line-height: 25px;
  284. font-size: 14px;
  285. text-align: center;
  286. }
  287. .banner .banner_c_t .banner_c_t_l .hidden_box li:hover {
  288. text-align: center;
  289. cursor: pointer;
  290. background-color: #f4f4f4;
  291. color: #f47a00;
  292. }
  293. .banner .banner_c_t .banner_c_t_l:hover .hidden_box {
  294. display: block;
  295. }
  296. .banner .banner_c_t .banner_c_t_c {
  297. background-color: rgb(253, 253, 253);
  298. width: 594px;
  299. height: 36px;
  300. border-left: 1px solid rgb(208, 204, 204);
  301. margin-left: 3px;
  302. padding-left: 5px;
  303. font-size: 14px;
  304. line-height: 36px;
  305. color: #9b9b9b;
  306. }
  307. .banner .banner_c_t .banner_c_t_r {
  308. background-color: #ff5000;
  309. width: 78px;
  310. height: 36px;
  311. border-radius: 25px;
  312. text-align: center;
  313. line-height: 36px;
  314. margin-right: 1px;
  315. cursor: pointer;
  316. color: white;
  317. }
  318. .banner .banner_c_b {
  319. background-color: rgb(255, 255, 255);
  320. width: 633px;
  321. height: 28px;
  322. display: flex;
  323. font-size: 12px;
  324. place-content: space-between;
  325. padding: 10px 0px 0px 10px;
  326. }
  327. .banner .banner_c_b li a:hover {
  328. color: #f47a00;
  329. }
  330. /* banner右侧二维码 */
  331. .banner .banner_t .banner_r {
  332. background-color: rgb(253, 253, 253);
  333. width: 62px;
  334. height:70px;
  335. margin: 10px auto;
  336. }
  337. .banner .banner_t .banner_r p {
  338. color: #ff0000;
  339. font-size: 12px;
  340. text-align: center;
  341. }
  342. .banner .banner_t .banner_r img{
  343. width: 62px;
  344. height: 62px;
  345. padding-top: 1px;
  346. }

代码运行效果:

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:完成的很好,没什么问题,继续加油
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post