欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Adaptive Placeholders

程序员文章站 2022-03-24 14:08:05
https://wisdmlabs.com/blog/create-adaptive-placeholders-using-css/ https://circleci.com/blog/adaptive-placeholders/ https://*.com/question ......

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

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

https://*.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>

  Adaptive Placeholders