UI 状态选择器

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UI状态选择器</title>
<style>
#box{
width: 100px;
height: 100px;
background-color: black;
}
#box:hover{
background-color: chocolate;
}
#box:active{
background-color: aqua;
}
#box2{
margin-top: 100px;
}
/当输入框获取到焦点的时候应用此样式/
#box2 input:focus{
border: 1px solid red;
outline: none;
}

    #box3{
        margin-top: 100px;
    }
    /*禁用状态下的样式*/
    #box3 input:disabled{
        background-color: blue;
    }
     /*起用状态下的样式*/
    #box3 input:enabled{
        background-color: aqua;
    }
    #box4{
        margin-top: 100px;
    }
    /*在输入框在只读状态下的样式*/
    #box4 input:read-only{
        background-color: pink;
    }
    /*在输入框可读可写状态下的样式*/
    #box4 input:read-write{
        background-color: coral;
    }
    #box5{
        margin-top: 100px;
    }
     /*checked 表示选中状态下checkbox 的样式*/
    #box5 input:checked + label{
        color: transparent;
    }
    /*表示半选择状态下的样式*/
    #box6 input:indeterminate + label{
        color: red;
    }

</style>

</head>
<body>
<div id="box"></div>
<div id="box2">
<input type="text">
</div>
<div id="box3">
<input type="text" disabled="disabled">
<input type="text">
<div id="box4">
<input type="text" disabled="disabled">
<input type="text" >
</div>
<div id="box5">
<input type="checkbox">
<label>男</label>
<input type="checkbox">
<label>女</label>
</div>
<div id="box6">
<input type="checkbox">
<label for="">男女</label>
</div>
</div>
</body>
<script>
var checkBox = document.querySelector("#box6>input")
//半选择状态下 只能由JS来设置
checkBox.indeterminate = true;
</script>
</html>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,...
    kiddings阅读 8,403评论 0 11
  • 本文是针对刚学编程的小白,都是一些基础知识,如果想了解更多深层一点的东西,欢迎移步本人博客!! 博客地址 点击跳转...
    西巴撸阅读 3,579评论 0 0
  • 1. tab列表折叠效果 html: 能源系统事业部 岗位名称: 工作地点 岗位名...
    lilyping阅读 5,905评论 0 1
  • 一、html5新特性 1.增加了一个专门用于绘画的元素canvas 2.增加了用于媒体播放的音频和视频元素 3.增...
    空谷悠阅读 3,723评论 0 2
  • 记得赫本女神说过,她很享受一个人的时光,并且爱看童话。 我也是,除了享受一个人,也爱看童话。 童话故事就像一面神奇...
    王子月阅读 3,411评论 0 1

友情链接更多精彩内容