Adaptive Placeholders

https://wisdmlabs.com/blog/create-adaptive-placeholders-using-css/

https://circleci.com/blog/adaptive-placeholders/

https://stackoverflow.com/questions/47983822/css-operator-adaptive-placeholder-contact-form-7-wordpress

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>Adaptive Placeholder – 自适应的占位符效果</title> 
    
    <style type="text/css">
    
    body {
    background-color: #FAFAFA;
}
.top-banner {
  background: #555;
}
input[type=text] {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  width: 100%;
  height: -webkit-calc(3em + 2px);
  height: calc(3em + 2px);
  margin: 0 0 1em;
  padding: 1em;
  border: 1px solid #cccccc;
  border-radius: 1.5em;
  background: #fff;
  resize: none;
  outline: none;
}
input[type=text][required]:focus {
  border-color: #00bafa;
}
input[type=text][required]:focus + label[placeholder]:before {
  color: #00bafa;
}
input[type=text][required]:focus + label[placeholder]:before, input[type=text][required]:valid + label[placeholder]:before {
  -webkit-transition-duration: .2s;
  transition-duration: .2s;
  -webkit-transform: translate(0, -1.5em) scale(0.9, 0.9);
  -ms-transform: translate(0, -1.5em) scale(0.9, 0.9);
  transform: translate(0, -1.5em) scale(0.9, 0.9);
}
input[type=text][required]:invalid + label[placeholder][alt]:before {
  content: attr(alt);
}
input[type=text][required] + label[placeholder] {
  display: block;
  pointer-events: none;
  line-height: 2.3em;
  margin-top: -webkit-calc(-3em - 2px);
  margin-top: calc(-3em - 2px);
  margin-bottom: -webkit-calc((3em - 1em) + 2px);
  margin-bottom: calc((3em - 1em) + 2px);
}
input[type=text][required] + label[placeholder]:before {
  content: attr(placeholder);
  display: inline-block;
  margin: 0 -webkit-calc(1em + 2px);
  margin: 0 calc(1em + 2px);
  padding: 0 2px;
  color: #898989;
  white-space: nowrap;
  -webkit-transition: 0.3s ease-in-out;
  transition: 0.3s ease-in-out;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff));
  background-image: -webkit-linear-gradient(top, #ffffff, #ffffff);
  background-image: linear-gradient(to bottom, #ffffff, #ffffff);
  -webkit-background-size: 100% 5px;
  background-size: 100% 5px;
  background-repeat: no-repeat;
  background-position: center;
}
    
    *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
.clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0}
.clearfix{*zoom:1}
.fl{float:left}
.fr{float:right}
.fl,.fr{_display:inline}
.top-banner {
	position:absolute;
	z-index: 999;
	left:0;
	top:0;
	height:40px;
	line-height:40px;
	padding:0 30px;
	width:100%;
	font-size: 13px;
	background-color: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-family: "宋体","Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif;
	font-size: 15px;
	/*text-shadow: 1px 1px 3px #333;*/
	/*box-shadow: 0 1px 0 #999;*/
}
.top-banner a {
	color: #fff;
	text-decoration: none;
}
    </style>
   <script type="text/javascript">
$(function() {
    $("input[id$=address]").qtip({
        content: '涂聚文告诉你,好样的'
    });
});
</script>

</head>

<body>
    <div style="width:400px;height:100px;margin:300px auto">
        <form>
            <input required='必须填写' type='text' class="name" id="name">
            <label alt='请输入姓名' placeholder='姓名'></label>
            <input required='必须填写' type='text' class="address" id="address">
            <label alt='请输入地址' placeholder='地址'></label>

        </form>
    </div>
<div class="footer-banner" style="width:728px; margin:200px auto 0"></div>
<script src="js/jquery.min.js"></script>
</body>
</html>

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值