国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

使用CSS3和Checkbox實現(xiàn)JQuery的一些效果

2024-07-11 08:34:38
字體:
供稿:網(wǎng)友

show()/hide()的實現(xiàn)

show()/hide()的實現(xiàn)主要控制元素的display屬性。
html:

XML/HTML Code復(fù)制內(nèi)容到剪貼板

<div id="box">  
    <input type="checkbox" id="sh"/>  
    <label for="sh">show/hide</label>  
    <div id="shbox">  
        點擊上面的show/hide實現(xiàn)show()/hide()   
    </div>  
</div>  

css:

CSS Code復(fù)制內(nèi)容到剪貼板

#box{   
    position:relative;   
}   
#box *:not(#shbox){   
    display:inline-block;   
}   
input{   
    position:absolute;   
    left:-10000000px;   
}   
:checked~#shbox{   
    display:none;   
}   
label{   
    width:100px;   
    height:30px;   
    line-height:30px;   
    text-align:center;   
    border:1px solid green;   
    position:absolute;   
    left:0px;   
    cursor:pointer;   
    border-radius:5px;   
}   
#shbox{   
    background:#ccc;   
    color:red;   
    width:200px;   
    height:200px;   
    border:1px solid blue;   
    box-sizing:border-box;   
    padding:50px;   
    position:absolute;   
    top:50px;   
}  

運行結(jié)果:https://jsfiddle.net/dwqs/1LykzL2f/1/embedded/result/
fadeIn()/fadeOut()的實現(xiàn)

fadeIn()/fadeOut()的實現(xiàn)主要是控制元素的opcity屬性。html依舊采用上面的,修改css如下:

CSS Code復(fù)制內(nèi)容到剪貼板

:checked~#shbox{   
    opacity:0;   
}  

fadeIn()/fadeOut()可以控制漸顯/漸退的速度,同樣給#shbox添加transition屬性可以模擬這個效果:

CSS Code復(fù)制內(nèi)容到剪貼板

#shbox{   
    transition:opacity 2s;   

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 湘潭县| 天祝| 高密市| 虞城县| 潞城市| 宜宾县| 西青区| 青川县| 安溪县| 石台县| 云阳县| 西平县| 遵义市| 合阳县| 济南市| 错那县| 纳雍县| 台东县| 墨江| 深泽县| 白朗县| 马尔康县| 桃源县| 新余市| 得荣县| 蒙山县| 尼勒克县| 区。| 博客| 金沙县| 时尚| 阿鲁科尔沁旗| 崇阳县| 陆良县| 时尚| 定边县| 湖南省| 临夏县| 兴山县| 建瓯市| 务川|