HTML5和CSS3实现登录界面

1.效果样式展示

完成后效果展示

2.HTML代码实现

<body>
    <!-- 创建一个大容器,将内部代码包裹 -->
    <div  class=".bigbox" id="loginform"> 
        <!-- 创建表单,在内部放入具体内容 -->
        <form   class="login" >
            <h1>login</h1>
            <!-- 引入用户名前方图标 -->
            <img src="../img/用户名.png" alt="">
            <input type="text" id="username" placeholder="用户名"  required>
            <!-- 引入输入密码前方图标 -->
            <img src="../img/锁子.png" alt="">
            <input type="text" id="password" placeholder="密码" required>
            <!-- 设置按钮 -->
            <button class="btn" id="login-btn" type="button">登录</button>
        </form>
    </div>
</body>

3.CSS代码实现

/* 创建登录注册页面的样式 */
*{
    /* 无法选中  整体感更强*/
    user-select: none;
}
body{
    background-image: url(../img/back.jpeg);
    /* 平铺 */
    background-repeat: no-repeat;
    /* 按照屏幕大小计算尺寸 */
    background-size: cover;
    /* fixed */
    background-attachment: fixed;
}
.login{
    /* 绝对定位 */
    position: absolute;
    /*设置位置 距离顶部50% 距离左侧50%*/
    top: 50%;
    margin-top: -200px;
    left: 50%;
    /* form表单宽度400px 这里回200px */
    margin-left: -200px;
    width: 400px;
    height: 400px;
    /* 边框锐度 */
    border-radius: 25px;
    background-color: #00000098;
    /* 居中 */
    text-align: center;
    padding: 5px 40px;
    /* 标准盒子 */
    box-sizing: border-box;
    /* 阴影 */
    box-shadow: 5px 10px 5px #161616a8;
}
.login h1{
    /* 引入字体 */
    font-family: "微软雅黑";
    color: white;
}
input{
    /* 设置背景颜色 */
    background-color: rgba(255, 255, 255, 0);
    /* 设置宽度高度 */
    width: 80%;
    height: 48px;
    /* 设置距离底部距离 */
    margin-bottom: 10px;
    /* 边框和底部 边框为0 给底部边框设置宽度大小颜色*/
    border: 0px;
    border-bottom: 2px solid silver;
    /* 点击白色的去除 */
    outline: none;
    /* 字体大小和颜色改变 */
    font-size: 22px;
    color: white;
}
form img{
    /* 设置大小 */
    width: 32px;
    /* 相对定位 */
    position: relative;
    /*设置高度 */
    top: 5px;
}
.btn{
    /* 设置宽度 设置边框锐度 */
    width: 40%;
    background-image: linear-gradient(120deg,#f6d365 0%,#fda085 100%);
    height: 50px;
    border-radius: 25px;
    margin-top: 10px;
    /* 去除下边框白色 */
    border: 0px;
    font-size: 25px;
    font-family: '微软雅黑';
}
/* 当按钮被点击的时候 */
.btn:hover{
    background-image:linear-gradient(to right,#dbb844 0%,#ef6c48 100%);
}

3.1.图片和图标字体说明

1.代码中包含从iconfont中下载的字体图标,有需要的话可以前往iconfont官网下载(具体下载方式在下篇文章中会详细介绍)。
2.图片在浏览器中搜索下载添加到项目中即可。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bubmerge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值