CSS输入框选中效果

CSS输入框选中效果

添加时间:2021-03-10 05:27:27
站长推荐丨赞助论坛,可获取海量资源终身免费下载权限奥!
举报 举报
收藏
预览
附件 附件
  • 模板类型模板类型:输入框
  • 模板颜色模板颜色:入门级
  • 下载积分下载积分:28 米粒
  • 下载权限下载权限:

    赞助会员

一款简约而不简单的输入框选中特效,提示文字会动画缩小,并移动到输入框的顶部,底部边框会有一个蓝色线条填充的动画特效,另外,登录按钮也有一个鼠标悬停的变色效果,可以直接拿来用,喜欢的就收下吧。
CSS输入框选中效果
分类:表单代码 > 输入框 难易:入门级

页面的head部分需要设置好CSS样式,由于难度不大,以下直接提供代码:

body {
  font-size: 20px;  
  font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
  background: #fff;
}

form {
  width: 300px;
  margin: 20px auto;
}

fieldset {
  position: relative;
  border: none;  
}

label {
  position: absolute;
  top: 18px;
  margin-left: 15px;
  color: rgba(0, 0, 0, 0.3);
  transform-origin: left;
  transition: all 0.3s ease;
}

input:focus ~ label {
  color: #26c7fc;  
}

input:focus ~ label,
input:valid ~ label {
  top: 0;
  transform: scale(0.6, 0.6);
}

input {
  font-size: 20px;  
  width: 100%;
  border: none;  
  margin-top: 10px;
  padding: 5px 15px;
}

input:focus {
  outline: none;
}

.after {
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, #26c7fc 50%, transparent 50%);
  background-color: rgba(0, 0, 0, 0.3);
  background-size: 200% 100%;
  background-position: 100% 0;
  transition: all 0.6s ease;
}

input:focus ~ .after {
  background-position: 0 0;
}

button {
  position: relative;
  width: 100%;
  font-size: 20px;  
  font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
  line-height: 2;
  margin-top: 20px;
  padding: 3px 10px;
  color: rgba(0, 0, 0, 0.4);
  background: white;
  border: none;
  background: linear-gradient(to right, #26c7fc 50%, transparent 50%);
  background-color: rgba(0, 0, 0, 0.3);
  background-size: 200% 100%;
  background-position: 100% 0;
  transition: all 0.6s ease;
  border-radius: 5px;
}

button:before {
  position: absolute;
  content: "立即登录";
  top: 2px;
  bottom: 2px;
  left: 2px;
  right: 2px;
  display: block;
  background-color: white;
  border-radius: 3px;
}

button:active,
button:focus,
button:hover {
  outline: none;
  background-position: 0 0;
  color: #26c7fc;
}

页面的body部分用三个fieldset,分别放置不同用处的input输入框还有底部的登录按钮,比较容易读懂,代码如下:

<fieldset>
  <input id="uname" type="text" name="uname" required>
  <label for="uname">用户名</label>
  <div class="after"></div>
</fieldset>
<fieldset>
  <input id="upswd" type="text" name="upswd" required>
  <label for="upswd">密码</label>
  <div class="after"></div>
</fieldset>
<fieldset>
  <button>立即登录</button>
</fieldset>
相关内容推荐
资源求助发帖
查看更多发帖

*

回帖描述:

*

链接类型:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
热点内容推荐
标题:CSS输入框选中效果

*

描述:
平均回复时间:3-10分钟
规则介绍:悬赏寻求论坛网友分享资源,站点对分享内容的准确性,合法性,版权等没有足够的监管能力。如果您发现资源不正确,无法使用,不符合法律法律等情况,您可以直接举报资源。站长将尽快核实您的举报,并根据情况,采取封号,退换米粒等处理。

*

回帖描述:

*

链接类型:

*

阅读权限:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
  • 背景波浪
  • 背景波浪
  • 波浪
  • 波浪
客服
在线咨询
周一 至 周日 9:00 ~ 22:00
QQ:1326974360
微信:juyoubuluo6688
客服热线
18205485173
工作日 9:00 ~ 18:00
微信扫码咨询
客户服务
欢迎咨询服务
咨询量较多时,请耐心等待
社群

关注公众号

获取更多资讯

扫码进群(QQ)

与更多大牛交流沟通

0.138736s