包含三个css文件,分别是base.css、common.css、login.css。
里面放一些固定的图片
里面放一些固定的图片
小兔鲜儿-新鲜、惠民、快捷!
在默认的浏览器中有很多默认的样式,所以我们要对其进行清除并且设置自己的默认样式
代码示例:
box-sizing: border-box;
}
/* 去除常见标签默认的 margin 和 padding */
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
li,
dl,
dt,
dd,
input {
margin: 0;
padding: 0;
}
/* 设置网页统一的字体大小、行高、字体系列相关属性 */
body {
box-sizing: border-box;
font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei",
"Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
color: #333;
}
/* 去除列表默认样式 */
ul,
ol {
list-style: none;
}
/* 去除默认的倾斜效果 */
em,
i {
font-style: normal;
}
/* 去除a标签默认下划线,并设置默认文字颜色 */
a {
text-decoration: none;
color: #333;
}
/* 设置img的垂直对齐方式为居中对齐,去除img默认下间隙 */
img {
vertical-align: middle;
}
/* 去除input默认样式 */
input {
border: none;
outline: none;
color: #333;
}
/* 双伪元素清除浮动 */
.clearfix::before,
.clearfix::after {
content: "";
display: table;
}
.clearfix::after {
clear: both;
}
.w {
width: 1240px;
margin: 0 auto;
}
/* 快捷导航栏开始 */
.shortcut {
height: 52px;
background-color: #333;
line-height: 52px;
}
.s {
position: absolute;
left: 0;
top: 0;
}
.shortcut ul {
float: right;
}
.shortcut li {
float: left;
}
.shortcut li:nth-child(13)::before {
content: '';
display: inline-block;
vertical-align: middle;
width: 11px;
height: 16px;
margin-right: 5px;
background-color: #27ba9b;
background: url(../images/sprites.png) no-repeat -160px -70px;
}
.sep {
color: #666;
margin: 0 15px;
}
.shortcut li a {
color: #dcdcdc;
font-size: 14px;
}
.shortcut li a:hover {
color: #27ba9b;
}
/* 快捷导航栏结束 */
/* 主导航栏开始 */
.main_nav {
height: 130px;
padding: 30px 0;
}
.logo {
float: left;
width: 207px;
height: 70px;
}
.logo h1 a {
display: block;
width: 207px;
height: 70px;
font-size: 0;
background: url(.././images/logo.png) no-repeat;
background-size: 100%;
}
.nav {
float: left;
margin-top: 5px;
margin-left: 35px;
}
.nav ul li {
float: left;
margin: 24px;
}
.nav ul li a {
padding-bottom: 5px;
}
.nav ul li:hover a {
border-bottom: 1px solid #27ba9b;
color: #27ba9b;
}
.search {
float: left;
margin-left: 35px;
border-bottom: 2px solid #e7e7e7;
}
.search::before {
content: '';
display: inline-block;
vertical-align: middle;
margin-top: -2px;
width: 18px;
height: 22px;
background: url(.././images/sprites.png) no-repeat -79px -69px;
}
.search input {
width: 172px;
height: 30px;
margin-top: 26px;
padding-left: 30px;
}
.search input::placeholder {
color: #ccc;
}
.car {
position: relative;
float: left;
width: 23px;
height: 23px;
background-color: #27ba9b;
margin-top: 30px;
margin-left: 15px;
background: url(.././images/sprites.png) no-repeat -119px -70px;
}
.car span {
position: absolute;
top: -8px;
right: -10px;
font-size: 13px;
line-height: 14px;
padding: 0 5px;
background-color: #e26237;
border-radius: 7px;
color: #fff;
}
/* 主导航栏结束 */
/* 底部模块开始 */
footer {
height: 645px;
}
.ft {
height: 50%;
}
.ft dl {
width: 25%;
float: left;
text-align: center;
margin-top: 79px;
color: #999;
}
.ft dl dt {
margin-bottom: 30px;
}
.kefu dd,
.guanzhu dd {
display: inline-block;
vertical-align: middle;
width: 92px;
height: 92px;
border: 1px solid #eee;
margin-right: 5px;
}
.kefu dd a,
.guanzhu dd a {
display: block;
margin-top: 22px;
width: 100%;
height: 100%;
font-size: 14px;
color: #999;
}
.kefu dd a::before,
.guanzhu dd a::before {
display: block;
width: 35px;
height: 31px;
content: '';
margin: 0 auto;
padding-bottom: 5px;
background: url(../images/sprites.png) no-repeat;
transition: all .5s;
}
.kefu .zaixian a::before {
background-position: -250px -70px;
}
.kefu .zaixian a:hover::before {
background-position: -204px -70px;
}
.kefu .wenti a::before {
background-position: -350px -70px;
}
.kefu .wenti a:hover::before {
background-position: -300px -70px;
}
.guanzhu .gongzhong a::before {
background-position: -250px -15px;
}
.guanzhu .gongzhong a:hover::before {
background-position: -205px -15px;
}
.guanzhu .weibo a::before {
background-position: -350px -15px;
}
.guanzhu .weibo a:hover::before {
background-position: -300px -15px;
}
.xiazai dd {
width: 105px;
height: 103px;
display: inline-block;
}
.xiazai dd a {
color: #999;
font-size: 14px;
}
.xiazai dd button {
width: 107px;
height: 32px;
background-color: #27ba9b;
color: #FFF;
margin-top: 10PX;
border: none;
cursor: pointer;
}
.xiazai dd img {
width: 100%;
height: 100%;
border: 1px solid #eee;
padding: 5px;
margin-top: -60px;
}
.ft .rexian dt {
margin-bottom: 40px;
}
.rexian dd:nth-of-type(1) {
font-size: 22px;
}
.rexian dd:nth-of-type(2) {
font-size: 15px;
margin-top: 5px;
}
.fb {
height: 50%;
background-color: #333;
}
.fb .fb_t {
height: 170px;
line-height: 175px;
width: 1393px;
margin: 0 auto 40px;
border-bottom: 1px solid #434343;
text-align: center;
}
.fb .fb_t ul li {
float: left;
width: 33.33%;
color: #fff;
font-size: 28px;
}
.fb .fb_t ul li::before {
content: '';
display: inline-block;
vertical-align: middle;
width: 58px;
height: 58px;
background: url(../images/sprites.png) no-repeat;
}
.fb .fb_t ul li:nth-child(2):before {
background-position: -65px 0;
}
.fb .fb_t ul li:nth-child(2):before {
background-position: -130px 0;
}
.fb .fb_b {
text-align: center;
color: #999;
}
.fb .fb_b i {
padding: 0 4px;
}
.fb .fb_b p a {
color: #999;
font-size: 14px;
}
.fb .fb_b p a:hover {
color: #27ba9b;
}
.fb .fb_b p:nth-child(2) {
margin-top: 5px;
}
/* 底部模块结束 */
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;
outline: none;
border: none;
cursor: pointer;
}
.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;
}
由于我们需要将登录时输入的用户名传到首页,所以我们需要用到本地存储技术,将用户名存储到浏览器中以便首页对其进行调用。
<script>
// 1、tab账户登录和二维码登录切换
// 获取tab-nav元素
const tab_nav = document.querySelector('.tab-nav')
const tab_pane = document.querySelectorAll('.tab-pane')
// 给tab-nav注册事件委托
tab_nav.addEventListener('click', function (e) {
// 判断是否点击的A链接
if (e.target.tagName === 'A') {
// 移除类
tab_nav.querySelector('.active').classList.remove('active')
// 添加类
e.target.classList.add('active')
// 切换下面的盒子
// 移除所有盒子
for (let i = 0; i < tab_pane.length; i++) {
tab_pane[i].style.display = 'none'
}
// 添加盒子
tab_pane[e.target.dataset.id].style.display = 'block'
}
})
// 2点击提交模块
// 2.1获取整个form表单
const form = document.querySelector('form')
const remember = document.querySelector('.remember')
const userName = document.querySelector('[name="username"]')
// 2.2给form注册提交事件
form.addEventListener('submit',function(e) {
e.preventDefault()
if(!remember.checked) {
return alert('请勾选同意用户协议')
}
// 将用户名存入本地存储中,以便后续首页的调用
localStorage.setItem('xtx_name',userName.value)
// 跳转到首页
location.href = './index.html'
})
</script>