css的:focus选择器用法介绍

css的:focus选择器用法介绍:
本章节通过代码实例介绍一下:focus选择器的作用,希望能够给需要的朋友带来帮助。
此选择器可以匹配获取焦点的元素。
接收键盘事件或其他用户输入的元素都可以使用:focus选择器。
浏览器支持:
(1).IE8和IE8以上浏览器支持此选择器。
(2).谷歌浏览器支持此选择器。
(3).火狐浏览器支持此选择器。
(4).Safari浏览器支持此选择器。
(5).Opera浏览器支持此选择器。
代码实例:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style>
input{
  width:200px;
  height:18px;
}
input:focus{
  color:blue;
}
</style>
</head>
<body>
<input type="text" value="蚂蚁部落">
</body>
</html>

 当文本框获取焦点的时候,能够设置它的其中的文本颜色。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=16356

更多内容可以参阅:http://www.softwhy.com/divcss/

猜你喜欢

转载自softwhy.iteye.com/blog/2274800
今日推荐