当前位置: 首页 > 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.lryc.cn/news/575460.html

相关文章:

  • 日语学习-日语知识点小记-进阶-JLPT-真题训练-N2阶段(4):2022年12月2023年12月
  • WPF中Converter基础用法
  • OceanBase SQL 引擎高级技术学习笔记(通俗篇)
  • 智能制造——58页智慧工厂解决方案【附全文阅读】
  • python中学物理实验模拟:斜面受力分析
  • Elasticsearch 中的精确搜索与模糊搜索
  • electron 如何配置 打开控制台
  • Android 开发 获取Debug 跟 Release 包的SHA1值
  • DeepSeek16-open-webui Pipelines开发填坑
  • C语言再出发:2025年AI时代的关键语言
  • 华为云Flexus+DeepSeek征文|基于华为云一键部署 Dify-LLM 平台,结合 MCP 工具与 DeepSeek 模型打造智能学习助手
  • 【stm32】HAL库开发——Cube配置基本定时器
  • 猴子爬山(华为OD)
  • 什么是回归测试?什么时候需要做回归测试?
  • bug复盘:MCP SSE Client 生命周期问题之context.Background() 的使用
  • B站视频下载技术揭秘:从浏览器抓包到FFmpeg音视频合成
  • 0 数学习题本
  • GraphQL注入 -- GPN CTF 2025 Real Christmas
  • 开发语言漫谈-R语言
  • Apache 支持 HTTPS
  • Hive3.1.3加载paimon-hive-connector-3.1-1.1.1.jar报错UnsatisfiedLinkError
  • C++ Programming Language —— 第3章:运算符
  • HDFS(Hadoop分布式文件系统)总结
  • 【unitrix】 4.7 库数字取反(not.rs)
  • 组织策略性陪伴顾问
  • Java后端中的并发控制:从锁机制到无锁编程的实现
  • 供应链管理:主要生产计划类型及其相关信息
  • Vue-14-前端框架Vue之应用基础嵌套路由和路由传参
  • 【fish-speech】新模型openaudio-s1-mini尝鲜
  • 【windows处理技巧】如何缩小PDF