猿问

checkbox选中之后怎么改变背景颜色

UI设计的,必须要这么做,点击之后右边的哪个小红点,还有小红圈怎么写?

白猪掌柜的
浏览 3897回答 4
4回答

北方的郎n_n

.cconte div input[type='checkbox']{    position: absolute;    left:-0.2rem;    top: .1rem;    -webkit-appearance: none;     appearance:none;    -moz-appearance:none;     display: block;    width: .16rem;    height: .16rem;    border:1px solid #B5B5B5;    outline: none;    border-radius: 2px;}.cconte div input[type='checkbox']:checked{    background: url(/crm/images/icon/866.png) no-repeat center /cover;    border:none;}

翻翻过去那场雪

一般组件是使用了背景图片,你可以审查元素的时候看到,然后单独加class,在class下面修改背景图片

慕田峪4524236

<span><div></div></span>&nbsp;<a href="#">男</a>&nbsp; &nbsp; &nbsp;&nbsp;<span><div></div></span>&nbsp;<a href="#">女</a>&nbsp; &nbsp; &nbsp; &nbsp; <script>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; window.onload = function(){&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var divs = document.getElementsByTagName("div"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;spans = document.getElementsByTagName("span");&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(var i = 0 ; i < divs.length ; i++){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spans[i].index = i;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spans[i].onclick = function(){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; divs[this.index].style.background = "red";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; }简单写了一个 ,可以做参考下。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答