国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 天柱县| 巫山县| 绵阳市| 海口市| 舟曲县| 镇安县| 互助| 岑巩县| 晋宁县| 迁安市| 张家港市| 洪雅县| 石棉县| 民乐县| 淮南市| 望奎县| 靖远县| 达州市| 赤峰市| 孝昌县| 萍乡市| 凉山| 夹江县| 高平市| 永康市| 龙川县| 腾冲县| 宁陵县| 若尔盖县| 南投市| 元朗区| 枣强县| 高阳县| 佛教| 华亭县| 阳曲县| 沛县| 凯里市| 阿坝| 石嘴山市| 宁安市|