伪类选择器focus使用

W3C定义:接收键盘事件或其他用户输入的元素都允许 :focus 选择器。

简单来说就是支持input标签。可以在CSS中采用input:focus{}进行操作。

如下是简单例子

<div class="outer"><input type="text" name="" id="" value="" /></div>

<style>
   .outer{
    width: 200px;
    height: 200px;
    background-color: red;
   }
   input:focus{
    background-color: green;
   }
</style>

                点击前                                    选中后

猜你喜欢

转载自blog.csdn.net/anoddguy/article/details/80924382