头闻号

博兴县贝利得化工有限公司

农药中间体|医药中间体|其它化工中间体

首页 > 新闻中心 > 科技常识:HTML+CSS实现动态背景登录页面
科技常识:HTML+CSS实现动态背景登录页面
发布时间:2023-02-01 10:11:28        浏览次数:5        返回列表

今天小编跟大家讲解下有关HTML+CSS实现动态背景登录页面 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关HTML+CSS实现动态背景登录页面 的相关资料,希望小伙伴们看了有所帮助。

1. 实现背景图片的动态变换

首先在HTML页面body板块中 添加图片div 代码如下:

<body><div class="bgk"><div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/1.jpg')"></div><div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/2.jpg')"></div><div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/3.jpg')"></div><div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/4.jpg')"></div></body>

再对图片进行css设计。你要对图片进行大小定位 那么以下代码肯定要首先编写:

`.bgk {margin: auto;position: absolute;width: 1366px;height: 672px;overflow: hidden; }`

位置设定ok以后 那么再对里面的图片进行设置。为了使图片能足够大覆盖页面 则代码必须有 background-size: cover;

要实现动态效果 那么你的css代码中必须有动画的设计:

-webkit-animation-name: kenburns; animation-name: kenburns; -webkit-animation-duration: 16s; animation-duration: 16s;-webkit-animation-timing-function: linear; animation-timing-function: linear;-webkit-animation-iteration-count: infinite; animation-iteration-count: infinite;-webkit-transform: scale(1.2); transform: scale(1.2);-webkit-filter: blur(10px); filter: blur(10px);

在绑定每个子元素选择器 有几张图片就绑定几个选择器:

.bgk-image:nth-child(1) {-webkit-animation-name: kenburns-1; animation-name: kenburns-1;z-index: 3; }.bgk-image:nth-child(2) {-webkit-animation-name: kenburns-2;animation-name: kenburns-2;z-index: 2;}.bgk-image:nth-child(3) {-webkit-animation-name: kenburns-3;animation-name: kenburns-3;z-index: 1;}.bgk-image:nth-child(4) {-webkit-animation-name: kenburns-4;animation-name: kenburns-4;z-index: 0;}

创建好选择器以后 你就可以预览你的动态背景图片变换了

2. 对登录表单的设计

在之前HTML页面中继续添加一个表单

<div class="form_login_div"> <form class="form_login" action="" method="post"> <label class="login_title">登录您的账户</label> <label class="username">用户名</label><input class="input_username" id="input_username" type="text" name="username" placeholder="邮箱/手机号"/> <label class="password">密&nbsp;码</label><input class="input_password" id="input_password" type="password" name="password" placeholder="请输入密码"/> <input type="submit" value="登录"/><br/> </form></div>

添加完表单之后 就要进行表单的样式设计。首先你得对表单规定一个圈子 限制它的宽度和高度

.form_login{ margin: auto; width:700px; height: 480px; top: 90px; left: 333px; position: absolute; border-radius: 15px; background: rgba(216,216,216,0.5); text-align: center; overflow: hidden;}

然后对表单里面的各个label进行定位和样式设计 这里可以自由设计。

对输入框的设计 我只贴出主要样式代码

outline:none; border:1px solid rgba(0,0,0,.49); -webkit-background-clip: padding-box; background-clip: padding-box;background:rgba(216,216,216,0.4) ;border-radius:6px; padding:7px;

当聚焦输入框的时候 可以增加一点绚丽色彩

.form_login input[type="text"]:focus,input[type="password"]:focus{ -webkit-transition:border linear .2s,-webkit-box-shadow linear .5s; border-color:rgba(255,128,0,.75);}

最后进行提交按钮的设计

text-shadow:0px -1px 0px #5b6ddc; outline:none;border:1px solid rgba(0,0,0,0.49); -webkit-background-clip: padding-box; background-clip: padding-box;border-radius:6px;cursor:pointer; background-color:#768ee4;

当鼠标放在提交按钮上面时 你可以适当进行一些动画效果设计

.form_login input[type="submit"]:hover{ background-color:#5f73e9; background-image:-webkit-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); background-image:-moz-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); background-image:-ms-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); background-image:-o-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); -webkit-box-shadow: inset 0px 1px 0px #aab9f4; box-shadow: inset 0px 1px 0px #aab9f4; margin-top:22px;}

最后整个设计完成 你可以看见你最终的效果了

以上所述是小编给大家介绍的HTML+CSS实现动态背景登录页面 希望对大家有所帮助 如果大家有任何疑问请给我留言 小编会及时回复大家的。在此也非常感谢大家对爱蒂网站的支持!

来源:爱蒂网