1. 程式人生 > >設定input 中placeholder的樣式

設定input 中placeholder的樣式

一、效果 在這裡插入圖片描述 二、程式碼

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		::-webkit-input-placeholder { /* Chrome/Opera/Safari */ 
			color: red;
		}
		::-moz-placeholder { /* Firefox 19+ */  
			color: red;
		}
		:-ms-input-placeholder { /* IE 10+ */ 
		 color: red;
		}
		:-moz-placeholder { /* Firefox 18- */ 
		 color: red;
		}
	</style>
</head>
<body>
	名字:<input type="" name="" placeholder="我是一個測試">
</body>
</html>

三、HTML input placeholder支援的屬性

  1. font properties
  2. color
  3. background properties
  4. word-spacing
  5. letter-spacing
  6. text-decoration
  7. vertical-align
  8. text-transform
  9. line-height
  10. text-indent
  11. opacity

eg1、 效果 在這裡插入圖片描述 程式碼:

input::-webkit-input-placeholder {
		   padding-left:30px;
		   opacity:0.5;
		}

剩下的大家自己去測哈~