媒体查询自适应登录界面

效果

 

 

html

通用样式

.box{

    width: 100vw;

    height: 100vh;

    background-color: rgb(29, 67, 89);

    .content{

        .login-wrapper{

            h1{

                text-align: center;

            }

            .login-form{

                .form-item{

                    margin: 20px 0;

                    span{

                        display: block;//变成块级元素

                        margin: 5px 20px;

                        font-weight: 100;

                    }

                    .input-item{

                        width: 100%;

                        border-radius: 40px;

                        padding: 20px;

                        box-sizing: border-box;//不会撑大盒子

                        font-size: 20px;

                        &:focus{

                            outline: none;//去掉点击时周围的虚线框

                        }

                    }

                }

                .login-btn{

                    width: 100%;

                    border-radius: 40px;

                    color: #fff;

                    border: 0;

                    font-weight: 100;

                    margin-top: 10px;

                    cursor: pointer;

                }

            }

            .divider{

                width: 100%;

                margin: 20px 0;

                text-align: center;

                display: flex;

                align-items: center;

                justify-content: center;

                span:nth-child(1){

                    flex: 1;

                }

                span:nth-child(3){

                    flex: 1;

                }

                .line{

                    display: inline-block;

                    max-width: 30%;

                    width: 30%;

                }

                .divider-text{

                    vertical-align: middle;

                    margin: 0 20px;

                    line-height: 0;

                    display: inline-block;

                    width: 100px;

                }

            }

            .other-login-wrapper{

                width: 100%;

                display: flex;

                justify-content: center;

                align-items: center;

            }

            .other-login-item{

                border: 1px solid rgb(214, 222, 228);

                padding: 10px;

                margin: 10px;

            }

        }

    }

}

大于手机尺寸样式

@media(min-width:767px){

    .box{

        background-color: rgb(29, 67, 89);

        .content{

            width: 85vw;

            height: 90vh;

            background: url(./asset/login_two.jpg) no-repeat;

            background-size: 90% 100%;

            position: absolute;

            // right: 15%;

            top: 50%;

            left: 50%;

            transform: translate(-50%,-50%);

            border-radius: 20px;

            background-color: #fff;

            .login-wrapper{

                width: 25vw;

                position: absolute;

                right: 15%;

                top: 50%;

                transform: translateY(-50%);

                h1{

                    text-align: center;

                    font-size: 45px;

                    color: rgb(81, 100, 115);

                    margin-bottom: 40px;

                }

                .login-form{

                    margin: 10px 0;

                    .form-item{

                        span{

                            color: rgb(81, 100, 115);

                        }

                        .input-item{

                            height: 60px;

                            border: 1px solid;

                        }

                    }

                    .login-btn{

                        height: 50px;

                        background-color: rgb(50, 72, 89);

                    }

                }

                .divider{

                    .line{

                        border-bottom: 1px solid rgb(214, 222, 228);

                    }

                }

                .other-login-item{

                    border-radius: 20px;

                    img{

                        width: 40px;

                        height: 40px;

                    }

                }

            }

        }

    }

}

手机端样式

@media (max-width:768px){

    .box{

        width: 100vw;

        height: 100vh;

        background: url(./asset/login_bg_phone.png) no-repeat;

        background-size: 100% 100%;

        display: flex;

        align-items: flex-start;

        justify-content: center;

        .login-wrapper{

            width: 70%;

            height: 60%;

            padding-top: 15%;

            h1{

                font-size: 30px;

                color: #fff;

            }

            .login-form{

                .form-item{

                    margin: 10px 0;

                    span{

                        color: rgb(113, 129, 141);

                    }

                }

                .login-btn{

                    height: 40px;

                    background-color: rgb(235, 95, 93);

                    color: #fff;

                }

            }

            .other-login-item{

                border-radius: 15px;

                img{

                    width: 35px;

                    height: 35px;

                }

            }

        }

    }

}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值