目录
综合案例:小兔鲜登录页面
需求:
1. 登录按钮点击的时候,需要先判断
- 如果没有勾选同意,则提示要勾选
- 如果勾选协议,则记住用户名和密码
- 登录成功则跳转到首页
注意,登录按钮需要先阻止默认行为
2. 打开页面时候,如果本地存储有数据, 则自动记录显示用户
名和密码,并勾选复选框
跳转需求:
如果是移动端打开,则跳转到移动端页面
如果本地存储有数据,则 显示 你好 xxxx,否则 显示 请跳转到注册页面
素材过多,因文章篇幅原因无法一 一展示
![](https://i-blog.csdnimg.cn/blog_migrate/3e247db9a69747c6472152eae2e0ca1d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6f56d4bc26bbdaafa9a86a77b09a40b8.png)
案例代码:CSS丨common
@charset "UTF-8";
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box;
/* 1 */
height: 0;
/* 1 */
overflow: visible;
/* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none;
/* 1 */
text-decoration: underline;
/* 2 */
text-decoration: underline dotted;
/* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-size: 100%;
/* 1 */
line-height: 1.15;
/* 1 */
margin: 0;
/* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input {
/* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select {
/* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box;
/* 1 */
color: inherit;
/* 2 */
display: table;
/* 1 */
max-width: 100%;
/* 1 */
padding: 0;
/* 3 */
white-space: normal;
/* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
* {
box-sizing: border-box;
}
body {
color: #333;
font: 14px/1.4 "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
}
ul, h1, h3, h4, p, dl, dd {
padding: 0;
margin: 0;
}
a {
text-decoration: none;
color: #333;
}
i {
font-style: normal;
}
input {
outline: none;
padding: 0;
border: none;
}
img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
ul {
list-style: none;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
.wrapper {
width: 1240px;
margin: 0 auto;
}
.sprites {
background-image: url(../images/sprites.png);
background-size: 400px 400px;
background-repeat: no-repeat;
}
.fl {
float: left;
}
.fr {
float: right;
}
.tc {
text-align: center;
}
.green {
color: #27BA9B;
}
.red {
color: #CF4444;
}
.mb10 {
margin-bottom: 10px;
}
.fz20 {
font-size: 20px;
}
.fz18 {
font-size: 18px;
}
.fz16 {
font-size: 16px;
}
.xtx-bread {
padding: 10px 0 25px 25px;
}
.xtx-bread a {
color: #999;
padding-right: 5px;
}
.xtx-bread a:hover {
color: #27BA9B;
}
.xtx-common-btn {
width: 180px;
height: 50px;
border-radius: 4px;
text-align: center;
line-height: 48px;
font-size: 16px;
color: #FFFFFF;
display: inline-block;
}
.xtx-common-btn[type="primary"] {
background: #27BA9B;
}
.xtx-common-btn[type="info"] {
background: #CCCCCC;
}
.xtx-check {
color: #999;
line-height: 30px;
cursor: pointer;
}
.xtx-check i {
vertical-align: middle;
}
.xtx-check i.icon-yixuanze {
color: #27BA9B;
display: none;
}
.xtx-check i.icon-weixuanze {
color: #999;
}
.xtx-check span {
vertical-align: middle;
}
.xtx-check input {
display: none;
}
.xtx-check input:checked ~ span {
color: #27BA9B;
}
.xtx-check input:checked ~ i.icon-yixuanze {
display: inline-block;
}
.xtx-check input:checked ~ i.icon-weixuanze {
display: none;
}
/** 顶部导航 **/
.xtx_topnav {
background-color: #333;
}
.xtx_topnav .xtx_navs {
height: 53px;
text-align: right;
line-height: 53px;
font-size: 0;
}
.xtx_topnav .xtx_navs li {
display: inline-block;
font-size: 14px;
}
.xtx_topnav .xtx_navs li:last-child a {
border-right: none;
}
.xtx_topnav .xtx_navs .mobile {
display: inline-block;
width: 20px;
height: 16px;
position: relative;
top: 3px;
background-position: -160px -70px;
}
.xtx_topnav .xtx_navs a {
display: inline-block;
line-height: 1;
padding: 0 15px;
border-right: 2px solid #666666;
color: #dcdcdc;
}
.xtx_topnav .xtx_navs a:hover {
color: #27BA9B;
}
/** 主导航及Logo **/
.xtx_header .wrapper {
display: flex;
align-items: center;
}
.xtx_header .xtx_logo {
width: 200px;
height: 132px;
text-indent: -999px;
background-image: url(../images/logo.png);
background-size: contain;
background-repeat: no-repeat;
background-position-x: center;
background-position-y: 20px;
}
.xtx_header .xtx_navs {
padding-left: 50px;
}
.xtx_header .xtx_navs li {
line-height: 1;
font-size: 16px;
margin-right: 50px;
position: relative;
float: left;
}
.xtx_header .xtx_navs li:after {
content: '';
display: none;
width: 30px;
height: 2px;
background-color: #27BA9B;
position: absolute;
left: 1px;
bottom: -7px;
}
.xtx_header .xtx_navs li:hover a, .xtx_header .xtx_navs li.active a {
color: #27BA9B;
}
.xtx_header .xtx_navs li:hover:after, .xtx_header .xtx_navs li.active:after {
display: block;
}
.xtx_header .xtx_search {
height: 38px;
padding-left: 20px;
}
.xtx_header .xtx_search_wrapper {
width: 175px;
height: 38px;
padding-left: 39px;
border-bottom: 1px solid #e7e7e7;
position: relative;
float: right;
}
.xtx_header .xtx_search_wrapper:before {
content: '';
display: block;
width: 17px;
height: 17px;
position: absolute;
left: 5px;
top: 10px;
background-image: url(../images/sprites.png);
background-size: 400px 400px;
background-position: -80px -70px;
}
.xtx_header .xtx_search_wrapper input {
width: 100%;
height: 100%;
font-size: 15px;
color: #999;
}
.xtx_header .xtx_search_wrapper input::-webkit-input-placeholder {
color: #ccc;
}
.xtx_header .xtx_search_cart {
display: block;
width: 22px;
height: 22px;
position: relative;
margin: 8px 12px 0 12px;
float: right;
background-position: -120px -70px;
}
.xtx_header .xtx_search_cart i {
position: absolute;
top: -5px;
left: 16px;
line-height: 1;
padding: 1px 6px;
font-style: normal;
font-size: 13px;
background-color: #E26237;
border-radius: 15px;
color: #fff;
}
/** 公共底部 **/
.xtx_footer .contact {
padding: 60px 0 40px 25px;
}
.xtx_footer .contact dl {
height: 190px;
text-align: center;
padding: 0 72px;
border-right: 1px solid #f2f2f2;
color: #999;
float: left;
}
.xtx_footer .contact dl:first-child {
padding-left: 0;
}
.xtx_footer .contact dl:last-child {
border-right: none;
padding-right: 0;
}
.xtx_footer .contact dt {
line-height: 1;
font-size: 18px;
}
.xtx_footer .contact dd {
margin: 36px 12px 0 0;
float: left;
}
.xtx_footer .contact dd:last-child {
margin-right: 0;
}
.xtx_footer .contact .chat, .xtx_footer .contact .feedback, .xtx_footer .contact .weixin, .xtx_footer .contact .weibo {
width: 92px;
height: 92px;
padding-top: 20px;
border: 1px solid #ededed;
}
.xtx_footer .contact .chat:before, .xtx_footer .contact .feedback:before, .xtx_footer .contact .weixin:before, .xtx_footer .contact .weibo:before {
content: '';
display: block;
width: 40px;
height: 30px;
margin: 0 auto 8px;
background-image: url(../images/sprites.png);
background-size: 400px 400px;
}
.xtx_footer .contact .chat:before {
background-position: -245px -70px;
}
.xtx_footer .contact .chat:hover:before {
background-position: -200px -70px;
}
.xtx_footer .contact .feedback:before {
background-position: -345px -70px;
}
.xtx_footer .contact .feedback:hover:before {
background-position: -295px -70px;
}
.xtx_footer .contact .weixin:before {
background-position: -247px -15px;
}
.xtx_footer .contact .weixin:hover:before {
background-position: -202px -15px;
}
.xtx_footer .contact .weibo:before {
background-position: -347px -15px;
}
.xtx_footer .contact .weibo:hover:before {
background-position: -297px -15px;
}
.xtx_footer .contact .qrcode {
width: 92px;
height: 92px;
padding: 7px;
border: 1px solid #ededed;
}
.xtx_footer .contact .download {
padding-top: 5px;
font-size: 14px;
}
.xtx_footer .contact .download span {
display: block;
}
.xtx_footer .contact .download a {
display: block;
line-height: 1;
padding: 10px 25px;
margin-top: 5px;
color: #fff;
border-radius: 2px;
background-color: #27BA9B;
}
.xtx_footer .contact .hotline {
padding-top: 20px;
font-size: 22px;
color: #666;
}
.xtx_footer .contact .hotline small {
display: block;
font-size: 15px;
color: #999;
}
.xtx_footer .extra {
background-color: #333;
}
.xtx_footer .slogan {
height: 178px;
line-height: 58px;
padding: 60px 100px;
border-bottom: 1px solid #434343;
text-align: justify;
}
.xtx_footer .slogan:after {
content: '';
display: inline-block;
width: 100%;
height: 0;
}
.xtx_footer .slogan a {
display: inline-block;
height: 58px;
line-height: 58px;
color: #fff;
font-size: 28px;
}
.xtx_footer .slogan a:before {
content: '';
width: 58px;
height: 58px;
margin-right: 10px;
float: left;
background-image: url(../images/sprites.png);
background-size: 400px 400px;
}
.xtx_footer .slogan .price:before {
background-position: 0 0;
}
.xtx_footer .slogan .express:before {
background-position: -65px 0;
}
.xtx_footer .slogan .quality:before {
background-position: -130px 0;
}
.xtx_footer .copyright {
height: 170px;
padding-top: 40px;
text-align: center;
color: #999;
font-size: 15px;
}
.xtx_footer .copyright p {
line-height: 1;
margin-bottom: 20px;
}
.xtx_footer .copyright a {
color: #999;
line-height: 1;
padding: 0 10px 0 6px;
border-right: 1px solid #999;
}
.xtx_footer .copyright a:last-child {
border-right: none;
}
button {
border: none;
padding: 0;
}
案例代码:CSS丨index
@charset "UTF-8";
/** 分类及焦点图 **/
.xtx_entry {
height: 500px;
background-color: #f2f2f2;
position: relative;
}
.xtx_category {
width: 250px;
background-color: rgba(0, 0, 0, 0.8);
position: absolute;
z-index: 9;
}
.xtx_category:hover .xtx_category_subset {
display: block;
}
.xtx_category_super li {
height: 50px;
padding: 0 20px 0 40px;
transition: background-color 0.25s;
cursor: pointer;
}
.xtx_category_super li:hover,
.xtx_category_super li.active {
background-color: #27BA9B;
}
.xtx_category_super a {
color: #fff;
font-size: 16px;
line-height: 50px;
}
.xtx_category_super a small {
font-size: 14px;
}
.xtx_category_super i {
display: block;
width: 12px;
height: 12px;
margin-top: 20px;
background-position: -75px -110px;
float: right;
}
.xtx_category_subset {
width: 990px;
height: 100%;
background-color: rgba(255, 255, 255, 0.9);
display: none;
position: absolute;
top: 0;
left: 250px;
}
.xtx_banner {
width: 1240px;
height: 500px;
overflow: hidden;
position: relative;
}
.xtx_banner:hover a {
opacity: 1;
}
.xtx_banner > a {
display: block;
width: 44px;
height: 44px;
border-radius: 50%;
margin-top: -22px;
opacity: 0;
transition: opacity 0.5s;
background-color: rgba(0, 0, 0, 0.1);
position: absolute;
top: 50%;
}
.xtx_banner > a.prev {
left: 270px;
background-position: 14px -59px;
}
.xtx_banner > a.next {
right: 20px;
background-position: -24px -59px;
}
.xtx_banner .indicator {
width: 990px;
text-align: center;
font-size: 0;
position: absolute;
left: 250px;
bottom: 22px;
}
.xtx_banner .indicator span {
display: inline-block;
width: 9px;
height: 9px;
margin: 0 8px;
cursor: pointer;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.43);
}
.xtx_banner .indicator span.active {
background-color: #fff;
}
/** 公共面板 **/
.xtx_panel .xtx_panel_header {
height: 115px;
padding: 40px 0;
}
.xtx_panel .xtx_panel_header h3 {
height: 35px;
line-height: 35px;
margin-left: 6px;
font-size: 32px;
font-weight: 400;
color: #333;
float: left;
}
.xtx_panel .xtx_panel_header small {
margin-left: 22px;
font-size: 16px;
color: #999;
}
.xtx_panel .xtx_panel_header .more {
line-height: 1;
margin-top: 14px;
font-size: 16px;
color: #999;
float: right;
}
.xtx_panel .xtx_panel_header .more i {
display: inline-block;
width: 16px;
height: 16px;
position: relative;
top: 1px;
background-position: 8px -106px;
}
.xtx_panel .xtx_panel_header .tabs-bar {
height: 35px;
padding-top: 13px;
font-size: 16px;
margin-right: 80px;
float: right;
}
.xtx_panel .xtx_panel_header .tabs-bar a {
padding: 2px 8px;
margin-left: 5px;
border-radius: 2px;
}
.xtx_panel .xtx_panel_header .tabs-bar a:hover,
.xtx_panel .xtx_panel_header .tabs-bar a.active {
background-color: #27BA9B;
color: #fff;
}
.xtx_panel .xtx_panel_goods_1 {
text-align: justify;
font-size: 0;
}
.xtx_panel .xtx_panel_goods_1:after {
content: "";
display: inline-block;
width: 306px;
height: 0;
}
.xtx_panel .xtx_panel_goods_1 a {
display: inline-block;
width: 306px;
height: 406px;
text-align: center;
}
.xtx_panel .xtx_panel_goods_1 img {
width: 306px;
height: 306px;
}
.xtx_panel .xtx_panel_goods_2 {
height: 610px;
}
.xtx_panel .xtx_panel_goods_2 li {
width: 240px;
height: 300px;
padding-top: 10px;
margin-left: 10px;
background-color: #fff;
border: 1px solid #fff;
overflow: hidden;
transition: 0.3s;
position: relative;
float: left;
}
.xtx_panel .xtx_panel_goods_2 li:hover {
border-color: #27BA9B;
}
.xtx_panel .xtx_panel_goods_2 li:hover .extra {
bottom: 0;
}
.xtx_panel .xtx_panel_goods_2 li:first-child {
height: 610px;
padding-top: 0;
margin-left: 0;
border: 0;
}
.xtx_panel .xtx_panel_goods_2 li:nth-last-child(-n + 4) {
margin-top: 10px;
}
.xtx_panel .xtx_panel_goods_2 a {
display: block;
}
.xtx_panel .xtx_panel_goods_2 .img-box {
width: 240px;
height: 160px;
padding: 0 33px;
text-align: center;
margin: 0 auto;
display: table-cell;
vertical-align: middle;
}
.xtx_panel .xtx_panel_goods_2 .meta {
height: 130px;
line-height: 1.3;
padding: 10px 22px 0;
font-size: 19px;
position: relative;
}
.xtx_panel .xtx_panel_goods_2 .name {
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.xtx_panel .xtx_panel_goods_2 .price {
font-size: 22px;
color: #CF4444;
position: absolute;
bottom: 10px;
}
.xtx_panel .xtx_panel_goods_2 .price small {
font-size: 17px;
}
.xtx_panel .xtx_panel_goods_2 .extra {
width: 100%;
height: 86px;
padding-top: 10px;
transition: bottom 0.3s;
background-color: #27BA9B;
position: absolute;
bottom: -86px;
}
.xtx_panel .xtx_panel_goods_2 .extra span {
display: block;
width: 124px;
line-height: 1;
padding: 9px 0 8px;
margin: 0 auto;
text-align: center;
font-size: 19px;
color: #fff;
}
.xtx_panel .xtx_panel_goods_2 .extra span:last-child {
font-size: 13px;
border-top: 1px solid #fff;
}
.xtx_panel .xtx_panel_goods_2 .label {
position: absolute;
left: 0;
bottom: 266px;
width: 188px;
height: 66px;
text-align: center;
line-height: 66px;
color: #fff;
font-size: 17px;
border-radius: 0 2px 2px 0;
background-color: rgba(0, 0, 0, 0.8);
position: relative;
}
.xtx_panel .xtx_panel_goods_2 .label span:first-child {
display: block;
width: 76px;
background-color: #000;
}
.xtx_panel .xtx_panel_goods_2 .label span:last-child {
width: 112px;
line-height: 1.4;
transform: translate(0, -50%);
position: absolute;
left: 76px;
right: 0;
top: 50%;
}
/** 新鲜好物 **/
.xtx_goods_new .xtx_panel_goods_1 a {
background-color: #f0f9f4;
transition: 0.5s;
position: relative;
top: 0;
}
.xtx_goods_new .xtx_panel_goods_1 a:hover {
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
top: -3px;
}
.xtx_goods_new .xtx_panel_goods_1 .name {
display: inline-block;
width: 100%;
margin: 12px 0 10px;
font-size: 22px;
}
.xtx_goods_new .xtx_panel_goods_1 .price {
font-size: 23px;
color: #CF4444;
}
.xtx_goods_new .xtx_panel_goods_1 small {
font-size: 16px;
}
/** 人气推荐 **/
.xtx_goods_popular {
padding-bottom: 42px;
}
.xtx_goods_popular .xtx_panel_goods_1 a {
transition: 0.5s;
}
.xtx_goods_popular .xtx_panel_goods_1 a:hover {
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
transform: translate(0, -3px);
}
.xtx_goods_popular .xtx_panel_goods_1 .title {
display: inline-block;
width: 100%;
line-height: 1;
margin: 20px 0 16px;
font-size: 22px;
}
.xtx_goods_popular .xtx_panel_goods_1 .alt {
font-size: 18px;
color: #999;
}
/** 热门品牌 **/
.xtx_goods_brand {
padding-bottom: 32px;
background-color: #f5f5f5;
}
.xtx_goods_brand .page-bar {
float: right;
}
.xtx_goods_brand .page-bar a {
display: inline-block;
width: 20px;
height: 20px;
line-height: 1;
margin-top: 10px;
background-color: #e2e2e2;
}
.xtx_goods_brand .page-bar a:hover,
.xtx_goods_brand .page-bar a.active {
background-color: #27BA9B;
}
.xtx_goods_brand .page-bar .prev {
margin-right: 5px;
background-position: -32px -106px;
transform: rotate(180deg);
}
.xtx_goods_brand .page-bar .next {
background-position: -32px -106px;
}
.xtx_goods_brand .xtx_goods {
height: 305px;
}
.xtx_goods_brand .xtx_goods li {
float: left;
font-size: 0;
}
.xtx_goods_brand .xtx_goods a {
margin-right: 10px;
}
.xtx_goods_brand .xtx_goods a img {
width: 240px;
height: 305px;
}
.xtx_goods_brand .xtx_goods a:last-child {
margin-right: 0;
}
/** 生鲜 **/
.xtx_goods_category {
padding-bottom: 80px;
}
/** 最新主题 **/
.xtx_goods_topic {
background-color: #f5f5f5;
padding-bottom: 52px;
}
.xtx_goods_topic li {
width: 406px;
margin-left: 11px;
transition: 0.5s;
float: left;
background: white;
}
.xtx_goods_topic li:hover {
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
transform: translate(0, -3px);
}
.xtx_goods_topic li:first-child {
margin-left: 0;
}
.xtx_goods_topic li a {
display: block;
height: 287px;
position: relative;
}
.xtx_goods_topic .meta {
width: 100%;
height: 100%;
color: #fff;
background-image: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent 50%);
position: absolute;
bottom: 0;
}
.xtx_goods_topic .meta .title {
height: 70px;
padding-left: 16px;
font-size: 22px;
position: absolute;
bottom: 0px;
}
.xtx_goods_topic .meta .title small {
display: block;
font-size: 19px;
color: #999;
}
.xtx_goods_topic .meta .price {
position: absolute;
bottom: 25px;
right: 16px;
display: block;
line-height: 1;
padding: 4px 8px 4px 7px;
color: #CF4444;
font-size: 17px;
background-color: #fff;
border-radius: 2px;
}
.xtx_goods_topic .meta .price small {
font-size: 15px;
}
.xtx_goods_topic .social {
height: 70px;
line-height: 70px;
padding: 0 20px;
font-size: 16px;
}
.xtx_goods_topic .social i {
display: inline-block;
width: 15px;
height: 14px;
margin-right: 5px;
position: relative;
top: 2px;
}
.xtx_goods_topic .social .like,
.xtx_goods_topic .social .liked,
.xtx_goods_topic .social .view {
float: left;
margin-right: 25px;
}
.xtx_goods_topic .social .reply {
float: right;
}
.xtx_goods_topic .social .like i {
background-position: -120px -110px;
}
.xtx_goods_topic .social .liked i {
background-position: -240px -110px;
}
.xtx_goods_topic .social .view i {
background-position: -160px -110px;
}
.xtx_goods_topic .social .reply i {
width: 17px;
height: 16px;
top: 4px;
background-position: -200px -110px;
}
.xtx-wrapper {
background: #f5f5f5;
line-height: 1.4;
}
.xtx-wrapper .container {
width: 1240px;
margin: 0 auto;
}
.xtx-wrapper .container .title {
height: 215px;
line-height: 215px;
font-size: 32px;
text-align: center;
font-weight: normal;
}
.xtx-bg-title {
width: 100%;
height: 180px;
padding-left: 213px;
background: no-repeat center / cover;
}
.xtx-bg-title h4 {
padding-top: 52px;
font-size: 32px;
font-weight: bold;
}
.xtx-bg-title p {
padding-top: 5px;
font-size: 20px;
}
.xtx-large-product {
margin-top: 40px;
display: flex;
justify-content: space-between;
}
.xtx-large-product .item {
width: 610px;
height: 420px;
background: white;
position: relative;
}
.xtx-large-product .item img {
width: 100%;
height: 320px;
display: block;
}
.xtx-large-product .item p {
padding-left: 55px;
}
.xtx-large-product .item p.tit {
padding-top: 22px;
font-size: 16px;
}
.xtx-large-product .item p.desc {
padding-top: 12px;
color: #999;
font-size: 14px;
}
.xtx-large-product .item .price {
position: absolute;
bottom: 37px;
right: 33px;
color: #CF4444;
font-size: 18px;
}
.xtx-large-product .item .tag {
width: 170px;
height: 40px;
border: 1px solid #fff;
border-radius: 4px;
position: absolute;
top: 17px;
left: 15px;
line-height: 40px;
color: #fff;
text-align: center;
font-size: 16px;
}
.xtx-mini-product {
padding-top: 40px;
padding-bottom: 20px;
}
.xtx-mini-product ul li {
width: 232px;
height: 320px;
float: left;
background: white;
margin-right: 20px;
text-align: center;
margin-bottom: 20px;
}
.xtx-mini-product ul li:nth-child(5n) {
margin-right: 0;
}
.xtx-mini-product ul li img {
width: 160px;
height: 160px;
display: block;
margin: 22px auto 0;
}
.xtx-mini-product ul li .tit {
padding-top: 23px;
font-size: 16px;
}
.xtx-mini-product ul li .desc {
padding-top: 12px;
color: #999;
}
.xtx-mini-product ul li .price {
font-size: 18px;
color: #CF4444;
padding-top: 16px;
}
.xtx-simpla-title {
height: 40px;
font-size: 28px;
text-align: center;
}
.xtx-large-brand {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.xtx-large-brand .item {
width: 610px;
height: 480px;
background: white;
margin-bottom: 40px;
}
.xtx-large-brand .item img {
width: 100%;
height: 320px;
display: block;
}
.xtx-large-brand .item .info {
padding: 0 35px;
position: relative;
}
.xtx-large-brand .item .info p.name {
padding-top: 22px;
padding-bottom: 12px;
font-size: 20px;
}
.xtx-large-brand .item .info p.name i {
width: 36px;
height: 18px;
line-height: 18px;
background: #27BA9B;
border-radius: 2px;
color: #fff;
font-size: 14px;
display: inline-block;
text-align: center;
}
.xtx-large-brand .item .info p.desc {
color: #999;
font-size: 14px;
height: 40px;
line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
padding-right: 40px;
}
.xtx-large-brand .item .info .price {
position: absolute;
top: 20px;
right: 35px;
color: #CF4444;
font-size: 18px;
}
.xtx-large-brand .item .comment {
padding: 15px 35px 0;
line-height: 40px;
color: #999;
}
.xtx-large-brand .item .comment .line {
width: 100%;
height: 1px;
background: #E4E4E4;
}
.xtx-large-brand .item .comment .red {
color: #CF4444;
}
.xtx-large-brand .item .comment .mr18 {
margin-right: 18px;
}
案例代码:CSS丨login
.xtx-login-header {
width: 1170px;
height: 132px;
margin: 0 auto;
}
.xtx-login-header .logo {
width: 200px;
height: 132px;
text-indent: -999px;
background-image: url(../images/logo.png);
background-size: contain;
background-position: center;
background-repeat: no-repeat;
float: left;
}
.xtx-login-header .home {
float: right;
margin-top: 82px;
font-size: 16px;
padding-right: 24px;
background: url(../images/login-enter.png) no-repeat right;
}
.xtx-login-main {
height: 488px;
background: url(../images/login-bg.png) no-repeat center/cover;
}
.xtx-login-main .wrapper {
width: 1170px;
height: 100%;
margin: 0 auto;
position: relative;
}
.xtx-login-main .wrapper .box {
width: 380px;
box-shadow: 0px 0px 25px 0px rgba(3, 3, 3, 0.14);
position: absolute;
top: 60px;
right: 100px;
background: #fff;
padding: 20px 40px;
}
.xtx-login-main .wrapper .box .tab-nav {
display: flex;
justify-content: space-between;
position: relative;
}
.xtx-login-main .wrapper .box .tab-nav::before {
content: "";
position: absolute;
left: 50%;
top: 8px;
width: 1px;
height: 20px;
background: #ededed;
}
.xtx-login-main .wrapper .box .tab-nav a {
font-size: 18px;
height: 35px;
line-height: 35px;
}
.xtx-login-main .wrapper .box .tab-nav a.active {
border-bottom: 2px solid #17bb9b;
}
.xtx-login-main .wrapper .box .tab-pane .code {
display: block;
margin: 44px auto;
}
.xtx-login-main .wrapper .box .tab-pane .link {
text-align: right;
padding-top: 12px;
}
.xtx-login-main .wrapper .box .tab-pane .link a {
color: #17bb9b;
}
.xtx-login-main .wrapper .box .tab-pane .input {
border: 1px solid #17bb9b;
width: 100%;
height: 36px;
margin-top: 17px;
display: flex;
background: #CFCDCD;
}
.xtx-login-main .wrapper .box .tab-pane .input .iconfont {
color: #fff;
width: 34px;
height: 34px;
text-align: center;
line-height: 34px;
font-size: 20px;
}
.xtx-login-main .wrapper .box .tab-pane .input input {
flex: 1;
padding-left: 15px;
background: #fff;
}
.xtx-login-main .wrapper .box .tab-pane .input input::placeholder {
color: #B3B3B3 !important;
}
.xtx-login-main .wrapper .box .tab-pane .agree {
color: #B3B3B3;
padding: 17px 0;
}
.xtx-login-main .wrapper .box .tab-pane .agree a {
color: #0673B1;
}
.xtx-login-main .wrapper .box .tab-pane .agree > label input {
/* display: none; */
}
.xtx-login-main .wrapper .box .tab-pane .agree > label input:checked + span {
color: #17bb9b;
}
.xtx-login-main .wrapper .box .tab-pane .button {
margin-bottom: 15px;
}
.xtx-login-main .wrapper .box .tab-pane .button .dl {
width: 100%;
height: 40px;
line-height: 40px;
text-align: center;
background: #17bb9b;
color: #fff;
display: block;
font-size: 16px;
margin-bottom: 17px;
}
.xtx-login-footer .copyright {
height: 115px;
padding-top: 40px;
text-align: center;
color: #999;
font-size: 15px;
}
.xtx-login-footer .copyright p {
line-height: 1;
margin-bottom: 20px;
}
.xtx-login-footer .copyright a {
color: #999;
line-height: 1;
padding: 0 10px 0 6px;
border-right: 1px solid #999;
}
.xtx-login-footer .copyright a:last-child {
border-right: none;
}
案例代码:CSS丨register
.xtx-wrapper {
background: #f5f5f5;
line-height: 1.4;
}
.xtx-wrapper .container {
width: 1240px;
margin: 0 auto;
padding: 50px 0;
}
.xtx-card {
width: 100%;
height: 800px;
background: #fff;
}
.xtx-card h3 {
font-size: 26px;
font-weight: normal;
color: #999999;
padding-left: 50px;
height: 180px;
line-height: 180px;
}
.xtx-form {
padding-left: 460px;
}
.xtx-form .xtx-form-item {
position: relative;
padding-bottom: 24px;
}
.xtx-form .xtx-form-item .msg {
color: #ff4d4f;
position: absolute;
left: 2px;
bottom: 2px;
}
.xtx-form .xtx-form-item.pl50 {
padding-left: 40px;
cursor: pointer;
}
.xtx-form .xtx-form-item span.iconfont {
position: absolute;
left: 15px;
top: 13px;
color: #666;
font-size: 18px;
}
.xtx-form .xtx-form-item i {
color: #27BA9B;
font-size: 14px;
}
.xtx-form .xtx-form-item input {
width: 300px;
height: 50px;
border: 1px solid #e4e4e4;
padding-left: 40px;
}
.xtx-form .xtx-form-item.error input {
border-color: #ff4d4f;
}
.xtx-form .xtx-form-item input::placeholder {
color: #cccccc !important;
}
.xtx-form .xtx-form-item .submit {
width: 300px;
height: 50px;
background: #27BA9B;
border-radius: 4px;
display: block;
font-size: 16px;
color: #fff;
text-align: center;
line-height: 50px;
cursor: pointer;
}
.xtx-form .xtx-form-item .code {
position: absolute;
left: 190px;
top: 16px;
width: 100px;
color: #27BA9B;
text-align: right;
}
.xtx-form .xtx-form-item .code.ing {
color: #cccccc;
}
.xtx-steps {
display: flex;
justify-content: space-between;
width: 720px;
height: 96px;
margin: 0 auto;
}
.xtx-steps .item {
position: relative;
width: 48px;
height: 48px;
}
.xtx-steps .item .text {
text-align: center;
width: 120px;
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 63px;
color: #999;
}
.xtx-steps .item .step {
border: 2px solid #e4e4e4;
color: #ccc;
background: #fff;
border-radius: 50%;
line-height: 46px;
text-align: center;
font-size: 28px;
z-index: 999;
display: block;
position: relative;
}
.xtx-steps .item::after, .xtx-steps .item::before {
content: "";
position: absolute;
top: 23px;
left: 24px;
height: 2px;
background: #e4e4e4;
width: 120px;
}
.xtx-steps .item::after {
transform: translateX(-100%);
}
.xtx-steps .item:first-child::after {
display: none;
}
.xtx-steps .item:last-child::before {
display: none;
}
.xtx-steps .item.active .text {
color: #27BA9B;
}
.xtx-steps .item.active .step {
background: #27BA9B;
color: #fff;
border-color: #27BA9B;
}
.xtx-steps .item.active::after, .xtx-steps .item.active::before {
content: "";
background: #27BA9B;
}
.xtx-form-label {
padding-left: 360px;
margin-top: 80px;
}
.xtx-form-label .xtx-form-item {
position: relative;
padding-bottom: 24px;
display: flex;
}
.xtx-form-label .xtx-form-item label {
width: 100px;
padding-right: 15px;
text-align: right;
font-size: 16px;
height: 50px;
line-height: 50px;
color: #999;
}
.xtx-form-label .xtx-form-item input {
width: 300px;
height: 50px;
border: 1px solid #e4e4e4;
padding-left: 10px;
}
.xtx-form-label .xtx-form-item input::placeholder {
color: #cccccc !important;
}
.xtx-form-label .xtx-form-item input:read-only {
background: #f5f5f5;
color: #999;
}
.xtx-form-label .xtx-form-item .submit {
width: 300px;
height: 50px;
background: #27BA9B;
border-radius: 4px;
display: block;
font-size: 16px;
color: #fff;
text-align: center;
line-height: 50px;
}
.xtx-form-label .xtx-form-item .captcha {
line-height: 50px;
height: 50px;
}
.xtx-form-label .xtx-form-item .captcha img {
width: 134px;
height: 50px;
}
.xtx-form-label .xtx-form-item .captcha a {
color: #27BA9B;
}
.xtx-form-label .xtx-form-item .code {
position: absolute;
left: 310px;
top: 16px;
color: #27BA9B;
}
.xtx-form-label .xtx-form-item .code.ing {
color: #cccccc;
}
.xtx-success-box {
padding-top: 250px;
text-align: center;
color: #999999;
}
.xtx-success-box .iconfont {
font-size: 80px;
color: #1DC779;
}
.xtx-success-box .tit {
font-size: 20px;
padding: 20px 0;
}
.xtx-success-box .desc {
font-size: 16px;
padding-bottom: 20px;
}
.xtx-success-box .btn {
width: 300px;
height: 50px;
background: #27BA9B;
border-radius: 4px;
display: block;
font-size: 16px;
color: #fff;
text-align: center;
line-height: 50px;
margin: 0 auto;
}
案例代码:HTML丨index
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>小兔鲜儿 - 新鲜 惠民 快捷!</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<link rel="shortcut icon" href="./favicon.ico">
<link rel="stylesheet" href="./css/common.css">
<link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_2143783_iq6z4ey5vu.css">
<script>
// 检测 userAgent(浏览器信息)
!(function () {
const userAgent = navigator.userAgent
// 验证是否为Android或iPhone
const android = userAgent.match(/(Android);?[\s\/]+([\d.]+)?/)
const iphone = userAgent.match(/(iPhone\sOS)\s([\d_]+)/)
// 如果是Android或iPhone,则跳转至移动站点
if (android || iphone) {
location.href = 'http://m.itcast.cn'
}
})()
</script>
</head>
<body>
<!-- 项部导航 -->
<div class="xtx_topnav">
<div class="wrapper">
<!-- 顶部导航 -->
<ul class="xtx_navs">
<li>
<a href="./login.html">请先登录</a>
</li>
<li>
<a href="./register.html">免费注册</a>
</li>
<li>
<a href="./center-order.html">我的订单</a>
</li>
<li>
<a href="./center.html">会员中心</a>
</li>
<li>
<a href="javascript:;">帮助中心</a>
</li>
<li>
<a href="javascript:;">在线客服</a>
</li>
<li>
<a href="javascript:;">
<i class="mobile sprites"></i>
手机版
</a>
</li>
</ul>
</div>
</div>
<!-- 头部 -->
<div class="xtx_header">
<div class="wrapper">
<!-- 网站Logo -->
<h1 class="xtx_logo"><a href="/">小兔鲜儿</a></h1>
<!-- 主导航 -->
<div class="xtx_navs">
<ul class="clearfix">
<li>
<a href="./index.html">首页</a>
</li>
<li>
<a href="./category01.html">生鲜</a>
</li>
<li>
<a href="./category01.html">美食</a>
</li>
<li>
<a href="./category01.html">餐厨</a>
</li>
<li>
<a href="./category01.html">电器</a>
</li>
<li>
<a href="./category01.html">居家</a>
</li>
<li>
<a href="./category01.html">洗护</a>
</li>
<li>
<a href="./category01.html">孕婴</a>
</li>
<li>
<a href="./category01.html">服装</a>
</li>
</ul>
</div>
<!-- 站内搜索 -->
<div class="xtx_search clearfix">
<!-- 购物车 -->
<a href="./cart-none.html" class="xtx_search_cart sprites">
<i>2</i>
</a>
<!-- 搜索框 -->
<div class="xtx_search_wrapper">
<input type="text" placeholder="搜一搜" onclick="location.href='./search.html'">
</div>
</div>
</div>
</div>
<!-- 分类及焦点图 -->
<div class="xtx_entry">
<div class="wrapper">
<!-- 分类 -->
<div class="xtx_category">
<!-- 顶级分类 -->
<ul class="xtx_category_super">
<li>
<a href="javascript:;">
生鲜
<small>水果</small>
<small>蔬菜</small>
</a>
<i class="sprites"></i>
</li>
<li class="active">
<a href="javascript:;">
美食
<small>面点</small>
<small>干果</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
电器
<small>数码产品</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
居家
<small>床品</small>
<small>四件套</small>
<small>被枕</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
洗护
<small>洗发洗护</small>
<small>美妆</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
孕婴
<small>奶粉</small>
<small>玩具</small>
<small>辅食</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
餐橱
<small>数码产品</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
服饰
<small>女装</small>
<small>男装</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
杂货
<small>户外</small>
<small>图书</small>
</a>
<i class="sprites"></i>
</li>
<li>
<a href="javascript:;">
品牌
<small>品牌制造</small>
</a>
<i class="sprites"></i>
</li>
</ul>
<!-- 子分类 -->
<div class="xtx_category_subset">
</div>
</div>
<!-- 焦点图 -->
<div class="xtx_banner">
<ul>
<li>
<a href="javascript:;">
<img src="./uploads/banner_1.png" alt="">
</a>
</li>
</ul>
<!-- 切换按钮 -->
<a href="javascript:;" class="prev sprites"></a>
<a href="javascript:;" class="next sprites"></a>
<!-- 指示器 -->
<div class="indicator">
<span></span>
<span></span>
<span class="active"></span>
<span></span>
<span></span>
</div>
</div>
</div>
</div>
<!-- 新鲜好物 -->
<div class="xtx_goods_new xtx_panel">
<div class="wrapper">
<!-- 面板头部 -->
<div class="xtx_panel_header">
<h3>新鲜好物<small>新鲜出炉 品质靠谱</small></h3>
<a href="./index-new.html" class="more">
查看全部<i class="sprites"></i>
</a>
</div>
<!-- 商品列表 -->
<div class="xtx_panel_goods_1">
<a href="javascript:;">
<img src="./uploads/new_goods_1.jpg" alt="">
<span class="name">睿米无线吸尘器F8</span>
<span class="price"><small>¥</small>899</span>
</a>
<a href="javascript:;">
<img src="./uploads/new_goods_2.jpg" alt="">
<span class="name">智能环绕3D空调</span>
<span class="price"><small>¥</small>1299</span>
</a>
<a href="javascript:;">
<img src="./uploads/new_goods_3.jpg" alt="">
<span class="name">广东软软糯米煲仔饭</span>
<span class="price"><small>¥</small>129</span>
</a>
<a href="javascript:;">
<img src="./uploads/new_goods_4.jpg" alt="">
<span class="name">罗西机械智能手表</span>
<span class="price"><small>¥</small>3399</span>
</a>
</div>
</div>
</div>
<!-- 人气推荐 -->
<div class="xtx_goods_popular xtx_panel">
<div class="wrapper">
<!-- 面板头部 -->
<div class="xtx_panel_header">
<h3>人气推荐<small>人气爆款 不容错过</small></h3>
</div>
<!-- 商品列表 -->
<div class="xtx_panel_goods_1">
<a href="javascript:;">
<img src="./uploads/popular_1.jpg">
<span class="title">特惠推荐</span>
<span class="alt">我猜得到 你的需要</span>
</a>
<a href="./index-hot.html">
<img src="./uploads/popular_2.jpg">
<span class="title">爆款推荐</span>
<span class="alt">人气好物推荐</span>
</a>
<a href="./index-one.html">
<img src="./uploads/popular_3.jpg">
<span class="title">场景使用一站买全</span>
<span class="alt">编辑精心整理推荐</span>
</a>
<a href="javascript:;">
<img src="./uploads/popular_4.jpg">
<span class="title">领券中心</span>
<span class="alt">发现更多超值优惠券</span>
</a>
</div>
</div>
</div>
<!-- 热门品牌 -->
<div class="xtx_goods_brand xtx_panel">
<div class="wrapper">
<div class="xtx_panel_header">
<h3>热门品牌<small>国际经典 品质保证</small></h3>
<div class="page-bar">
<a href="javascript:;" class="prev sprites"></a>
<a href="javascript:;" class="next sprites active"></a>
</div>
</div>
<!-- 商品列表 -->
<div class="xtx_goods">
<ul>
<li>
<a href="./index-brand.html">
<img src="./uploads/brand_goods_1.jpg" alt="">
</a>
<a href="./brand-list.html">
<img src="./uploads/brand_goods_2.jpg" alt="">
</a>
<a href="javascript:;">
<img src="./uploads/brand_goods_3.jpg" alt="">
</a>
<a href="javascript:;">
<img src="./uploads/brand_goods_4.jpg" alt="">
</a>
<a href="javascript:;">
<img src="./uploads/brand_goods_5.jpg" alt="">
</a>
</li>
</ul>
</div>
</div>
</div>
<!-- 分类商品 -->
<div class="xtx_goods_category xtx_panel">
<div class="wrapper">
<!-- 生鲜 -->
<div class="xtx_panel_header">
<h3>生鲜</h3>
<a href="javascript:;" class="more">
查看全部<i class="sprites"></i>
</a>
<div class="tabs-bar">
<a href="javascript:;" class="active">水果</a>
<a href="javascript:;">蔬菜</a>
<a href="javascript:;">肉禽蛋</a>
<a href="javascript:;">裤装</a>
<a href="javascript:;">衬衫</a>
<a href="javascript:;">内衣</a>
</div>
</div>
<!-- 商品列表 -->
<div class="xtx_panel_goods_2">
<ul class="clearfix">
<li>
<a href="javascript:;">
<img src="./uploads/fresh_goods_cover.jpg" alt="">
</a>
<div class="label">
<span>生鲜馆</span>
<span>全场3件8折</span>
</div>
</li>
<li>
<!-- 商品图片 -->
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_1.jpg" alt="">
</div>
</a>
<!-- 商品信息 -->
<div class="meta">
<p class="name">美威 智利原味三文鱼排 240g/袋 4片装</p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>59</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_2.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">红功夫 麻辣小龙虾1.5kg 4-6钱/25-32只</p>
<p class="flag">火锅食材</p>
<p class="price"><small>¥</small>71.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_3.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">三都港 冷冻无公害黄花鱼 700g 2条 袋装</p>
<p class="flag">海鲜水产</p>
<p class="price"><small>¥</small>49.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_4.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">渔公码头 大连鲜食入味 即食海参 辽参刺参 调味海</p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>899</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_5.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">越南进口白心火龙果4个 装 标准果 单果400-550g </p>
<p class="flag"></p>
<p class="price"><small>¥</small>29</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_6.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">广西沃柑 柑橘1.5kg</p>
<p class="flag">新鲜水果</p>
<p class="price"><small>¥</small>59</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_7.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">进口 牛油果 6个装 单果重约130-180g</p>
<p class="flag">新鲜水果</p>
<p class="price"><small>¥</small>39.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/fresh_goods_8.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">泰国进口山竹5A级 500g </p>
<p class="flag">新鲜水果</p>
<p class="price"><small>¥</small>29.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
</ul>
</div>
<!-- 服饰 -->
<div class="xtx_panel_header">
<h3>服饰</h3>
<a href="javascript:;" class="more">
查看全部<i class="sprites"></i>
</a>
<div class="tabs-bar">
<a href="javascript:;" class="active">行李箱</a>
<a href="javascript:;">男士包袋</a>
<a href="javascript:;">女士包袋</a>
<a href="javascript:;">钱包及小提袋</a>
<a href="javascript:;">男鞋</a>
<a href="javascript:;">女鞋</a>
<a href="javascript:;">拖鞋</a>
</div>
</div>
<!-- 商品列表 -->
<div class="xtx_panel_goods_2">
<ul class="clearfix">
<li>
<a href="javascript:;">
<img src="./uploads/clothes_goods_cover.jpg" alt="">
</a>
<div class="label">
<span>服饰馆</span>
<span>3折狂欢</span>
</div>
</li>
<li>
<!-- 商品图片 -->
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_1.jpg" alt="">
</div>
</a>
<!-- 商品信息 -->
<div class="meta">
<p class="name">人本秋季厚底帆布鞋 韩版低帮增高学生</p>
<p class="flag"></p>
<p class="price"><small>¥</small>55</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_2.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">迪士尼真皮针扣表带宽度 14-16mm规格双色压纹 女表带</p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>20.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_3.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">三都港 冷冻无公害黄花鱼 700g 2条 袋装</p>
<p class="flag">海鲜水产</p>
<p class="price"><small>¥</small>209</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_4.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">ONLY夏季新款高腰宽松 七分阔腿裙裤休闲裤</p>
<p class="flag"></p>
<p class="price"><small>¥</small>274.5</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_5.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">拉夫劳伦t恤男正品 </p>
<p class="flag">圆领短袖</p>
<p class="price"><small>¥</small>99</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_6.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">李宁跑步鞋男鞋空气 弧2018春季款</p>
<p class="flag"></p>
<p class="price"><small>¥</small>79</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_7.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">Dickies男鞋2020春季 英伦休闲工装鞋低帮</p>
<p class="flag"></p>
<p class="price"><small>¥</small>179</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/clothes_goods_8.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">北极绒春夏季纯棉背心 男士修身纯色打底</p>
<p class="flag"></p>
<p class="price"><small>¥</small>69</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
</ul>
</div>
<!-- 餐厨 -->
<div class="xtx_panel_header">
<h3>餐厨</h3>
<a href="javascript:;" class="more">
查看全部<i class="sprites"></i>
</a>
<div class="tabs-bar">
<a href="javascript:;" class="active">水果</a>
<a href="javascript:;">蔬菜</a>
<a href="javascript:;">肉禽蛋</a>
<a href="javascript:;">裤装</a>
<a href="javascript:;">衬衫</a>
<a href="javascript:;">内衣</a>
</div>
</div>
<!-- 商品列表 -->
<div class="xtx_panel_goods_2">
<ul class="clearfix">
<li>
<a href="javascript:;">
<img src="./uploads/kitchen_goods_cover.jpg" alt="">
</a>
<div class="label">
<span>餐厨馆</span>
<span>大额优惠<br>等你来拿</span>
</div>
</li>
<li>
<!-- 商品图片 -->
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_1.jpg" alt="">
</div>
</a>
<!-- 商品信息 -->
<div class="meta">
<p class="name">创意可爱不锈钢便携餐具 套装筷子便携三件套</p>
<p class="flag"></p>
<p class="price"><small>¥</small>5.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_2.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">三金西瓜霜竹炭牙刷软毛 成人家用家庭装</p>
<p class="flag"></p>
<p class="price"><small>¥</small>20.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_3.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">朴(TOPOTO)大卫免手 洗平板拖把拓扑懒人木地 板刮刮乐桶拖布</p>
<p class="flag"></p>
<p class="price"><small>¥</small>129</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_4.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">ONLY夏季新款高腰宽松 七分阔腿裙裤休闲裤</p>
<p class="flag"></p>
<p class="price"><small>¥</small>274.5</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_5.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">金纺不伤手柔顺剂 妈妈的选择</p>
<p class="flag"></p>
<p class="price"><small>¥</small>29</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_6.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">洁成绵柔抹布洗碗巾超 值5片装 洗锅刷碗</p>
<p class="flag"></p>
<p class="price"><small>¥</small>10.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_7.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">大卫双驱动旋转拖把桶 免手洗拓扑拖布地拖墩布 </p>
<p class="flag"></p>
<p class="price"><small>¥</small>159</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/kitchen_goods_8.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">斧头牌(AXE)去污地板 清洁剂2L 柠檬清香 </p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>22.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
</ul>
</div>
<!-- 居家 -->
<div class="xtx_panel_header">
<h3>居家</h3>
<a href="javascript:;" class="more">
查看全部<i class="sprites"></i>
</a>
<div class="tabs-bar">
<a href="javascript:;" class="active">咖啡具</a>
<a href="javascript:;">水具酒具</a>
<a href="javascript:;">锅具</a>
<a href="javascript:;">餐具</a>
<a href="javascript:;">功能厨具</a>
<a href="javascript:;">茶具</a>
<a href="javascript:;">清洁保鲜</a>
</div>
</div>
<!-- 商品列表 -->
<div class="xtx_panel_goods_2">
<ul class="clearfix">
<li>
<a href="javascript:;">
<img src="./uploads/home_goods_cover.jpg" alt="">
</a>
<div class="label">
<span>居家馆</span>
<span>全场满减</span>
</div>
</li>
<li>
<!-- 商品图片 -->
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_1.jpg" alt="">
</div>
</a>
<!-- 商品信息 -->
<div class="meta">
<p class="name">菜鸟异常专用链接 非请 勿拍</p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>8999</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_2.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">【中盐软水盐】汉斯希 尔家用软水机适配</p>
<p class="flag"></p>
<p class="price"><small>¥</small>65</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_3.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">云米净水壶家用直饮台式 净水机渗透过滤自来水</p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>129</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_4.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">ztk恒温调奶器配件玻璃壶 炖盅</p>
<p class="flag">海鲜年货</p>
<p class="price"><small>¥</small>129</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_5.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">荞麦枕头单人枕芯双人 护颈椎枕头芯</p>
<p class="flag"></p>
<p class="price"><small>¥</small>29</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_6.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">Bear/小熊 LLJ-B04G1 家用多功能切碎机 电动</p>
<p class="flag">料理机</p>
<p class="price"><small>¥</small>10.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_7.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">荣事达薄饼机春饼春卷皮 家用博饼机电饼铛 </p>
<p class="flag"></p>
<p class="price"><small>¥</small>159</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
<li>
<a href="javascript:;">
<div class="img-box">
<img src="./uploads/home_goods_8.jpg" alt="">
</div>
</a>
<div class="meta">
<p class="name">美式双人实木床 红实木 显档次</p>
<p class="flag"></p>
<p class="price"><small>¥</small>22.9</p>
</div>
<!-- 其它 -->
<div class="extra">
<a href="javascript:;">
<span>找相似</span>
<span>发现现多宝贝></span>
</a>
</div>
</li>
</ul>
</div>
</div>
</div>
<!-- 最新主题 -->
<div class="xtx_goods_topic xtx_panel">
<div class="wrapper">
<div class="xtx_panel_header">
<h3>最新专题</h3>
<a href="javascript:;" class="more">
查看全部<i class="sprites"></i>
</a>
</div>
<div class="xtx_topic">
<ul class="clearfix">
<li>
<a href="javascript:;">
<img src="./uploads/topic_goods_1.jpg" alt="">
<div class="meta">
<p class="title">
吃这些美食才不算辜负自己
<small>餐厨起居洗护好物</small>
</p>
<span class="price"><small>¥</small>29.9起</span>
</div>
</a>
<div class="social">
<span class="like">
<i class="sprites"></i>1220
</span>
<span class="view">
<i class="sprites"></i>1800
</span>
<span class="reply">
<i class="sprites"></i>1220
</span>
</div>
</li>
<li>
<a href="javascript:;">
<img src="./uploads/topic_goods_2.jpg" alt="">
<div class="meta">
<p class="title">
吃这些美食才不算辜负自己
<small>餐厨起居洗护好物</small>
</p>
<span class="price"><small>¥</small>29.9起</span>
</div>
</a>
<div class="social">
<span class="liked">
<i class="sprites"></i>1220
</span>
<span class="view">
<i class="sprites"></i>1800
</span>
<span class="reply">
<i class="sprites"></i>1220
</span>
</div>
</li>
<li>
<a href="javascript:;">
<img src="./uploads/topic_goods_3.jpg" alt="">
<div class="meta">
<p class="title">
吃这些美食才不算辜负自己
<small>餐厨起居洗护好物</small>
</p>
<span class="price"><small>¥</small>29.9起</span>
</div>
</a>
<div class="social">
<span class="like">
<i class="sprites"></i>1220
</span>
<span class="view">
<i class="sprites"></i>1800
</span>
<span class="reply">
<i class="sprites"></i>1220
</span>
</div>
</li>
</ul>
</div>
</div>
</div>
<!-- 公共底部 -->
<div class="xtx_footer clearfix">
<div class="wrapper">
<!-- 联系我们 -->
<div class="contact clearfix">
<dl>
<dt>客户服务</dt>
<dd class="chat">在线客服</dd>
<dd class="feedback">问题反馈</dd>
</dl>
<dl>
<dt>关注我们</dt>
<dd class="weixin">公众号</dd>
<dd class="weibo">微博</dd>
</dl>
<dl>
<dt>下载APP</dt>
<dd class="qrcode">
<img src="./uploads/qrcode.jpg">
</dd>
<dd class="download">
<span>扫描二维码</span>
<span>立马下载APP</span>
<a href="javascript:;">下载页面</a>
</dd>
</dl>
<dl>
<dt>服务热线</dt>
<dd class="hotline">
400-0000-000
<small>周一至周日 8:00-18:00</small>
</dd>
</dl>
</div>
</div>
<!-- 其它 -->
<div class="extra">
<div class="wrapper">
<!-- 口号 -->
<div class="slogan">
<a href="javascript:;" class="price">价格亲民</a>
<a href="javascript:;" class="express">物流快捷</a>
<a href="javascript:;" class="quality">品质新鲜</a>
</div>
<!-- 版权信息 -->
<div class="copyright">
<p>
<a href="javascript:;">关于我们</a>
<a href="javascript:;">帮助中心</a>
<a href="javascript:;">售后服务</a>
<a href="javascript:;">配送与验收</a>
<a href="javascript:;">商务合作</a>
<a href="javascript:;">搜索推荐</a>
<a href="javascript:;">友情链接</a>
</p>
<p>CopyRight © 小兔鲜儿</p>
</div>
</div>
</div>
</div>
<script>
// 如果本地存储有数据,则 显示 你好 xxxx
// 否则 显示 请跳转到注册页面
let li = document.querySelector('.xtx_navs li:first-child')
let obj = JSON.parse(localStorage.getItem('pink'))
if (obj) {
li.innerHTML = ` <a href="#">你好,${obj.username} 欢迎来到小兔鲜世界</a>`
}
</script>
</body>
</html>
案例代码:HTML丨login
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>小兔鲜儿 - 新鲜 惠民 快捷!</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="./css/common.css">
<link rel="stylesheet" href="./css/login.css">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_2143783_iq6z4ey5vu.css">
</head>
<body>
<!-- 登录头部 -->
<div class="xtx-login-header">
<h1 class="logo"></h1>
<a class="home" href="./index.html">进入网站首页</a>
</div>
<!-- 登录内容 -->
<div class="xtx-login-main">
<div class="wrapper">
<form action="">
<div class="box">
<div class="tab-nav">
<a href="javascript:;" class="active">账户登录</a>
<a href="javascript:;">二维码登录</a>
</div>
<div class="tab-pane">
<div class="link">
<a href="javascript:;">手机验证码登录</a>
</div>
<div class="input">
<span class="iconfont icon-zhanghao"></span>
<input required type="text" placeholder="请输入用户名称/手机号码" name="username">
</div>
<div class="input">
<span class="iconfont icon-suo"></span>
<input required type="password" placeholder="请输入密码" name="password">
</div>
<div class="agree">
<label for="my-checkbox">
<input type="checkbox" value="1" id="my-checkbox" class="remember" name="agree">
<span class="iconfont icon-xuanze"></span>
</label>
我已同意 <a href="javascript:;">《服务条款》</a href="javascript:;"> 和 <a>《服务条款》</a>
</div>
<div class="button clearfix">
<button type="submit" class="dl">登 录</button>
<!-- <a class="dl" href="./center.html">登 录</a> -->
<a class="fl" href="./forget.html">忘记密码?</a>
<a class="fr" href="./register.html">免费注册</a>
</div>
</div>
<div class="tab-pane" style="display: none;">
<img class="code" src="../images/code.png" alt="">
</div>
</div>
</form>
</div>
</div>
<!-- 登录底部 -->
<div class="xtx-login-footer">
<!-- 版权信息 -->
<div class="copyright">
<p>
<a href="javascript:;">关于我们</a>
<a href="javascript:;">帮助中心</a>
<a href="javascript:;">售后服务</a>
<a href="javascript:;">配送与验收</a>
<a href="javascript:;">商务合作</a>
<a href="javascript:;">搜索推荐</a>
<a href="javascript:;">友情链接</a>
</p>
<p>CopyRight © 小兔鲜儿</p>
</div>
</div>
<script>
// 需求:
// 1. 登录按钮点击的时候,需要先判断
// 如果没有勾选同意,则提示要勾选
// 如果勾选协议,则记住用户名和密码
// 登录成功则跳转到首页
// 注意,登录按钮需要先阻止默认行为
let dl = document.querySelector('.dl')
// 复选框
let remember = document.querySelector('.remember')
let username = document.querySelector('[name=username]')
let password = document.querySelector('[name=password]')
dl.addEventListener('click', function (e) {
e.preventDefault()
if (!remember.checked) {
alert('请勾选协议')
return
}
let obj = {
username: username.value,
password: password.value,
}
// console.log(obj)
localStorage.setItem('pink', JSON.stringify(obj))
// 跳转到新的页面
location.href = './index.html'
})
// 2. 打开页面时候,如果本地存储有数据, 则自动记录显示用户名和密码,并勾选复选框
let obj = JSON.parse(localStorage.getItem('pink'))
if (obj) {
username.value = obj.username
password.value = obj.password
// 如果有数据则默认勾选
remember.checked = true
}
</script>
</body>
</html>
案例代码:HTML丨register
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>小兔鲜儿 - 新鲜 惠民 快捷!</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<!-- <link rel="shortcut icon" href="./favicon.ico"> -->
<link rel="stylesheet" href="./css/common.css">
<link rel="stylesheet" href="./css/register.css">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_2143783_iq6z4ey5vu.css">
</head>
<body>
<!-- 项部导航 -->
<div class="xtx_topnav">
<div class="wrapper">
<!-- 顶部导航 -->
<ul class="xtx_navs">
<li>
<a href="./login.html">请先登录</a>
</li>
<li>
<a href="./register.html">免费注册</a>
</li>
<li>
<a href="./center-order.html">我的订单</a>
</li>
<li>
<a href="./center.html">会员中心</a>
</li>
<li>
<a href="javascript:;">帮助中心</a>
</li>
<li>
<a href="javascript:;">在线客服</a>
</li>
<li>
<a href="javascript:;">
<i class="mobile sprites"></i>
手机版
</a>
</li>
</ul>
</div>
</div>
<!-- 头部 -->
<div class="xtx_header">
<div class="wrapper">
<!-- 网站Logo -->
<h1 class="xtx_logo"><a href="/">小兔鲜儿</a></h1>
<!-- 主导航 -->
<div class="xtx_navs">
<ul class="clearfix">
<li>
<a href="./index.html">首页</a>
</li>
<li>
<a href="./category01.html">生鲜</a>
</li>
<li>
<a href="./category01.html">美食</a>
</li>
<li>
<a href="./category01.html">餐厨</a>
</li>
<li>
<a href="./category01.html">电器</a>
</li>
<li>
<a href="./category01.html">居家</a>
</li>
<li>
<a href="./category01.html">洗护</a>
</li>
<li>
<a href="./category01.html">孕婴</a>
</li>
<li>
<a href="./category01.html">服装</a>
</li>
</ul>
</div>
<!-- 站内搜索 -->
<div class="xtx_search clearfix">
<!-- 购物车 -->
<a href="./cart-none.html" class="xtx_search_cart sprites">
<i>2</i>
</a>
<!-- 搜索框 -->
<div class="xtx_search_wrapper">
<input type="text" placeholder="搜一搜" onclick="location.href='./search.html'">
</div>
</div>
</div>
</div>
<div class="xtx-wrapper">
<div class="container">
<!-- 卡片 -->
<div class="xtx-card">
<h3>新用户注册</h3>
<form class="xtx-form">
<div data-prop="username" class="xtx-form-item">
<span class="iconfont icon-zhanghao"></span>
<input name="username" type="text" placeholder="设置用户名称">
<span class="msg"></span>
</div>
<div data-prop="phone" class="xtx-form-item">
<span class="iconfont icon-shouji"></span>
<input name="phone" type="text" placeholder="输入手机号码 ">
<span class="msg"></span>
</div>
<div data-prop="code" class="xtx-form-item">
<span class="iconfont icon-zhibiaozhushibiaozhu"></span>
<input name="code" type="text" placeholder="短信验证码">
<span class="msg"></span>
<a class="code" href="javascript:;">发送验证码</a>
</div>
<div data-prop="password" class="xtx-form-item">
<span class="iconfont icon-suo"></span>
<input name="password" type="password" placeholder="设置6至20位字母、数字和符号组合">
<span class="msg"></span>
</div>
<div data-prop="confirm" class="xtx-form-item">
<span class="iconfont icon-suo"></span>
<input name="confirm" type="password" placeholder="请再次输入上面密码">
<span class="msg"></span>
</div>
<div class="xtx-form-item pl50">
<i class="iconfont icon-queren"></i>
已阅读并同意<i>《用户服务协议》</i>
</div>
<div class="xtx-form-item">
<button class="submit">下一步</button>
<!-- <a class="submit" href="javascript:;">下一步</a> -->
</div>
</form>
</div>
</div>
</div>
<!-- 公共底部 -->
<div class="xtx_footer clearfix">
<div class="wrapper">
<!-- 联系我们 -->
<div class="contact clearfix">
<dl>
<dt>客户服务</dt>
<dd class="chat">在线客服</dd>
<dd class="feedback">问题反馈</dd>
</dl>
<dl>
<dt>关注我们</dt>
<dd class="weixin">公众号</dd>
<dd class="weibo">微博</dd>
</dl>
<dl>
<dt>下载APP</dt>
<dd class="qrcode">
<img src="./uploads/qrcode.jpg">
</dd>
<dd class="download">
<span>扫描二维码</span>
<span>立马下载APP</span>
<a href="javascript:;">下载页面</a>
</dd>
</dl>
<dl>
<dt>服务热线</dt>
<dd class="hotline">
400-0000-000
<small>周一至周日 8:00-18:00</small>
</dd>
</dl>
</div>
</div>
<!-- 其它 -->
<div class="extra">
<div class="wrapper">
<!-- 口号 -->
<div class="slogan">
<a href="javascript:;" class="price">价格亲民</a>
<a href="javascript:;" class="express">物流快捷</a>
<a href="javascript:;" class="quality">品质新鲜</a>
</div>
<!-- 版权信息 -->
<div class="copyright">
<p>
<a href="javascript:;">关于我们</a>
<a href="javascript:;">帮助中心</a>
<a href="javascript:;">售后服务</a>
<a href="javascript:;">配送与验收</a>
<a href="javascript:;">商务合作</a>
<a href="javascript:;">搜索推荐</a>
<a href="javascript:;">友情链接</a>
</p>
<p>CopyRight © 小兔鲜儿</p>
</div>
</div>
</div>
</div>
<script>
// (function () {
// // 表单验证的模块
// let num = 0
// }());
// (function () {
// // 登录模块
// let num = 0
// }());
(function () {
// 需求①: 发送验证码
// 用户点击之后,显示 05秒后重新获取
// 时间到了,自动改为 重新获取
let code = document.querySelector('.code')
code.addEventListener('click', function () {
// 倒计时读秒操作
this.innerHTML = '05秒后重新获取'
let num = 5
let timer = setInterval(function () {
num--
code.innerHTML = `0${num}秒后重新获取`
if (num === 0) {
code.innerHTML = `重新获取`
// 清除定时器
clearInterval(timer)
}
}, 1000)
})
// 需求②: 用户名验证(注意封装函数 verifyxxx)
// 正则 /^ [a - zA - Z0 - 9 - _]{ 6, 10 } $ /
// 如果不符合要求,则出现提示信息 并 return false
// 否则 则返回return true
// 之所以返回 布尔值,是为了 最后的提交按钮做准备
// [name=username] css 属性选择器
let username = document.querySelector('[name=username]')
// console.log(username)
// 鼠标离开需要验证, 点击下一步也需要验证,那我们为何不封装一个函数呢?
username.addEventListener('change', verifyUsername)
// 验证用户名的函数
function verifyUsername() {
// console.log(11)
let span = username.nextElementSibling
// 开始验证 正则 1. 定义规则 2. 检测
let reg = /^[a-zA-Z0-9-_]{6,10}$/
if (!reg.test(username.value)) {
// console.log('wrong')
span.innerHTML = '请输入6~10的字符'
return false
}
// console.log('right')
span.innerHTML = ''
return true
}
// 需求③: 手机号验证
// 正则: /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
// 其余同上
let phone = document.querySelector('[name=phone]')
phone.addEventListener('change', verifyPhone)
// 验证手机号的函数
function verifyPhone() {
// console.log(11)
let span = phone.nextElementSibling
// 开始验证 正则 1. 定义规则 2. 检测
let reg = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
if (!reg.test(phone.value)) {
// console.log('wrong')
span.innerHTML = '请输入11位的手机号码'
return false
}
// console.log('right')
span.innerHTML = ''
return true
}
// 需求④: 验证码验证
// 正则 /^\d{6}$/
// 其余同上
let codeInput = document.querySelector('input[name=code]')
codeInput.addEventListener('change', verifyCode)
// 验证手机号的函数
function verifyCode() {
// console.log(11)
let span = codeInput.nextElementSibling
// 开始验证 正则 1. 定义规则 2. 检测
let reg = /^\d{6}$/
if (!reg.test(codeInput.value)) {
// console.log('wrong')
span.innerHTML = '请输入6位数字'
return false
}
// console.log('right')
span.innerHTML = ''
return true
}
// 需求⑤: 密码验证
// 正则 /^[a-zA-Z0-9-_]{6,20}$/
// 其余同上
let pass = document.querySelector('input[name=password]')
pass.addEventListener('change', verifyPass)
// 验证手机号的函数
function verifyPass() {
// console.log(11)
let span = pass.nextElementSibling
// 开始验证 正则 1. 定义规则 2. 检测
let reg = /^[a-zA-Z0-9-_]{6,20}$/
if (!reg.test(pass.value)) {
// console.log('wrong')
span.innerHTML = '请输入6~20位密码'
return false
}
// console.log('right')
span.innerHTML = ''
return true
}
// 需求⑥: 再次密码验证
// 如果本次密码不等于上面输入的密码则返回错误信息
// 其余同上
let confirm = document.querySelector('[name=confirm]')
confirm.addEventListener('change', verifyConfirm)
function verifyConfirm() {
let span = confirm.nextElementSibling
if (confirm.value !== pass.value) {
span.innerHTML = '两次密码不一致'
return false
}
// console.log('right')
span.innerHTML = ''
return true
}
// 需求⑦: 我同意模块
// 切换类 .icon-queren2 则是默认选中样式
let icon = document.querySelector('.icon-queren')
icon.addEventListener('click', function () {
this.classList.toggle('icon-queren2')
})
// 需求⑧: 提交按钮模块
// 使用 submit 提交事件
// 如果上面的每个模块,返回的是 false 则 阻止提交
// 如果没有勾选同意协议,则提示 需要勾选
// 在提交之前先验证
let form = document.querySelector('form')
form.addEventListener('submit', function (e) {
// alert(11)
// e.preventDefault()
// e.preventDefault()
// 怎么阻止提交 (怎么阻止默认行为 )
// 我们如果没有验证成功,不允许提交 阻止提交的行为
// 这样说明验证不通过
// verifyUsername() === false
if (!verifyUsername()) {
// 阻止提交
// console.log(111);
e.preventDefault()
}
if (!verifyPhone()) {
// 阻止提交
e.preventDefault()
}
if (!verifyCode()) {
// 阻止提交
e.preventDefault()
}
if (!verifyPass()) {
// 阻止提交
e.preventDefault()
}
if (!verifyConfirm()) {
// 阻止提交
e.preventDefault()
}
// 勾选模块 必须勾选才能通过
// classList.add() 添加
// classList.remove() 移除
// classList.toggle() 切换
// classList.contains() 看看有没有包含某个类,如果有则返回true,么有则返回false
if (!icon.classList.contains('icon-queren2')) {
alert('请勾选同意协议')
e.preventDefault()
}
})
}());
</script>
</body>
</html>
Web APIs的相关学习资料:
前期更新笔记内容: Web API 基本认知 / 获取DOM元素 / 设置/修改DOM元素内容和元素属性 / 定时器-间歇函数 / 事件基础 / 高阶函数 / 环境对象 / 综合案例-Tab栏切换 / DOM节点 /DOM 时间对象/DOM 重绘和回流/ DOM- 事件对象/DOM- 事件流 / DOM- 事件委托 +综合案例 /Web APIs DOM- 网页特效篇-滚动事件和加载事件 /元素大小和位置 / 综合案例 /Web APIs BOM- 操作浏览器-Window对象 / swiper 插件 /本地存储 / 之综合案例 /Web APIs 正则表达式
黑马前端专栏干货多多,关注再学,好方便~
2022年前端学习路线图:课程、源码、笔记,技术栈 另外此线路图实时更新!需要课后资料的友友们,可以直接告诉我