美文网首页
UI 状态选择器

UI 状态选择器

作者: Simon_s | 来源:发表于2016-09-27 19:57 被阅读17次

<!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>

相关文章

  • CSS3-新增选择器

    属性选择器 结构伪类选择器 UI伪类选择器 UI伪类选择器只有当元素处于某种状态时才起作用,在默认状态下不起作用.

  • UI 状态选择器

    UI状态选择器 #box{width: 100px;height: 100...

  • CSS选择器

    简单概括一下CSS的选择器 基本选择器 属性选择器 伪类选择器 动态伪类 常用的四个锚点伪类 UI元素状态伪类 :...

  • CSS3 积累(2)之结构伪类选择器

    介绍 伪类选择器主要有动态伪类选择器、UI元素状态伪类选择器、结构伪类选择器和伪元素等,这篇主要讲讲什么是结构伪类...

  • CSS进阶知识点--CSS3伪类选择器和伪元素

    伪类选择器 动态伪类(锚点伪类、用户行为伪类) UI元素状态伪类 CSS3结构伪类 否定选择器 伪元素 动态伪类 ...

  • css新增属性

    UI元素伪类选择器 :focus 选择获得焦点的元素 :enabled 被用来指定元素处于可用状态是的样式 :di...

  • Element 小问题记录

    Element UI框架bug:Element UI级联选择器高度bug解决 (原文链接)

  • CSS3选择器

    1CSS选择器的分类 基本选择器 层次选择器 伪类选择器 动态伪类选择器 目标伪类选择器 语言伪类选择器 UI元素...

  • UI元素状态伪类选择器

    :focus选择器 :focus选择器被用来指定“表单元素”获得光标焦点时使用的样式,主要在单行文本框text、多...

  • 01.22 伪类选择器

    伪类选择器 普通选择器是选中某一个标签,伪类选择器是选中标签某种状态 1.语法:普通选择器:状态{} 2.创建状态...

网友评论

      本文标题:UI 状态选择器

      本文链接:https://www.haomeiwen.com/subject/fjfhyttx.html