老师请检查 还有就是active和focus的区别在哪
来源:2-17 编程练习
尤尼酱
2019-04-07 17:35:56
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>动态伪类</title>
<style type="text/css">
/*此处写代码*/
input:hover{
border-color:red;
}
input[type="text"]:focus{
background-color:orange;
}
input[type="password"]:focus{
background-color:yellow;
}
</style>
</head>
<body>
<!-- 此处写代码 -->
用户名:<input type="text" name="text"><br><br>
密码:<input type="password" name="password">
</body>
</html>1回答
你好同学, 效果实现了。它们的区别如下:
1.focus表示元素获得焦点,一般用于输入框 ,获取焦点就是鼠标点击input之后,会有一个光标

只要光标在还input框中,样式就会一直有
2.active是元素处于激活状态(鼠标在元素上按下还没有松开)。同学可以把代码改成active,会发现只有一直按住鼠标,样式才会有。当鼠标松开,active中的样式就立马没有了。
祝学习愉快 ,望采纳。
相似问题