如何在css开关上放置内容

时间:2016-11-09 06:07:04

标签: html5 css3

我在css开关上放置内容时遇到问题

这是我的代码

/* Css */

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}
<!-- Html: -->

<label class="switch"></label>
<input type="checkbox" />
<div class="slider round"></div>

任何帮助都将受到高度赞赏

1 个答案:

答案 0 :(得分:0)

使用adjacent sibling selector:checked selector。例如:

&#13;
&#13;
div:before {
    content: "";
}

input:checked + div:before{
  content: 'foo';
}
&#13;
<input type="checkbox" />
<div></div>
&#13;
&#13;
&#13;

JSFiddle of your situation