当前位置: 首页 > news >正文

前端项目3-01:登录页面

一、效果图

二、全部代码

<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>码农魔盒</title><style>.bg{position: fixed;top: 0;left:0;object-fit: cover;width: 100vw;height: 100vh;}.box{width: 950px;height: 450px;box-shadow: 0 5px 15px rgba(0,0,0,.8);display: flex;position: fixed;top: 50%;left:50%;transform: translate(-50%,-50%);box-sizing: border-box;padding: 20px;background: rgba(47,1,74,.8);}.left{width: 65%;}.left>img{display: block;width: 100%;height: 100%;object-fit: cover;}.right{width: 35%;height: 100%;box-sizing: border-box;padding: 0 20px;}h1{color: #fff;text-align: center;margin-top: 45px;}.inputItem{height: 44px;padding: 0;padding-left: 8px;border: none;background: #fff;outline: none;width: 100%;font-size: 16px;margin-top: 20px;}.btn{background: linear-gradient(to right,#65CBF7,#B3A5FC);box-shadow: 0 5px 15px rgba(255, 255, 255, .6);color: #9C3493;font-weight: bold;border: none;border-radius: 30px;height: 46px;width: 100%;font-size: 18px;display: block;margin: auto;margin-top: 50px;}</style></head><body><img src="img/bg.jpg" alt="" class="bg"><div class="box"><div class="left"><img src="img/bg.jpg" alt=""></div><div class="right"><h1>用户登录</h1><input type="text" class="inputItem" placeholder="请输入账号"><input type="password" class="inputItem" placeholder="请输入密码"><button class="btn">登录</button></div></div></body>
</html>

三、代码详解

.bg{position: fixed;top: 0;left:0;object-fit: cover;width: 100vw;height: 100vh;
}
  • position: fixed:固定定位,相对于浏览器窗口

  • top:0; left:0:从左上角开始

  • object-fit: cover:图片覆盖整个区域,可能会裁剪

  • 100vw/100vh:占满整个视口宽度和高度

.box{width: 950px;height: 450px;box-shadow: 0 5px 15px rgba(0,0,0,.8);display: flex;position: fixed;top: 50%;left:50%;transform: translate(-50%,-50%);box-sizing: border-box;padding: 20px;background: rgba(47,1,74,.8);
}
  • box-shadow:添加阴影效果,增强立体感

  • display: flex:使用 Flexbox 布局

  • top:50%; left:50%:定位到页面中心

  • transform: translate(-50%,-50%):向上向左移动自身宽高的 50%,实现精确居中

  • box-sizing: border-box:让内边距包含在元素总宽高内

  • rgba(47,1,74,.8):半透明深紫色背景

.left{width: 65%;
}
.left>img{display: block;width: 100%;height: 100%;object-fit: cover;
}
  • .left:左侧区域占 65% 宽度

  • display: block:将图片转为块级元素

  • object-fit: cover:图片覆盖整个区域

.right{width: 35%;height: 100%;box-sizing: border-box;padding: 0 20px;
}
  • .right:右侧区域占 35% 宽度

  • padding: 0 20px:左右内边距 20px

h1{color: #fff;text-align: center;margin-top: 45px;
}
  • color: #fff:白色文字

  • text-align: center:文字居中对齐

  • margin-top: 45px:顶部外边距 45px

.inputItem{height: 44px;padding: 0;padding-left: 8px;border: none;background: #fff;outline: none;width: 100%;font-size: 16px;margin-top: 20px;
}
  • height: 44px:统一高度 44px

  • padding-left: 8px:左侧内边距 8px

  • border: none:无边框

  • outline: none:取消聚焦时的默认边框

  • width: 100%:宽度占满父容器

.btn{background: linear-gradient(to right,#65CBF7,#B3A5FC);box-shadow: 0 5px 15px rgba(255, 255, 255, .6);color: #9C3493;font-weight: bold;border: none;border-radius: 30px;height: 46px;width: 100%;font-size: 18px;display: block;margin: auto;margin-top: 50px;
}
  • linear-gradient:从左到右的渐变色背景

  • box-shadow:白色半透明阴影

  • color: #9C3493:深紫色文字

  • border-radius: 30px:圆角边框

  • margin: auto:水平居中

  • margin-top: 50px:顶部外边距 50px

http://www.lqws.cn/news/527455.html

相关文章:

  • 实测推荐:一款能看4K直播的万能播放器,支持多端同步
  • 全面比较帮你确定何时选择SLM而非LLM
  • C# .NET Framework 中的高效 MQTT 消息传递
  • React HOC(高阶组件-补充篇)
  • Django 零基础起步:开发你的网站第一步
  • IDE如何快速切换JLINK版本
  • Redis 持久化
  • Axure版AntDesign 元件库-免费版
  • 广州华锐互动:技术与创意双驱动的 VR 先锋​
  • Python 中的 random 模块
  • 49-有效的字母异位词
  • 设计模式精讲 Day 14:命令模式(Command Pattern)
  • Web基础关键_001_HTML(一)
  • docker环境下java参数传递与获取
  • FANUC机器人教程:用户坐标系标定及其使用方法
  • 学习永无止境
  • 程序的更新总结
  • 简易服务器(TCP)
  • 川翔云电脑全新上线:三维行业高效云端算力新选择
  • Kotlin环境搭建与基础语法入门
  • 鸿蒙边缘智能计算架构实战:多线程图像采集与高可靠缓冲设计
  • MIT 6.S081—环境配置和初步学习day01(VMware和Ubuntu安装)
  • Go 语言中的接口
  • 黑马ReactDay02
  • 《告别一换就崩:前端游戏物理引擎适配层设计哲学》
  • Vue样式绑定与条件渲染详
  • C++新纪元:深入C++11/14/17/20核心特性与名企面试精粹(完整版)--8000字硬核解析 | 腾讯/阿里/字节真题实战
  • 数据分享:交通数据-地铁乘坐站记录数据
  • 随记:WebMvcConfigurationSupport 和WebMvcConfigurer 的区别
  • 第4篇:响应处理——返回数据给客户端(Gin文件下载,JSON,XML等返回)