最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js實(shí)現(xiàn)一鍵換膚效果

 更新時(shí)間:2022年07月01日 15:29:01   作者:Cheryl71  
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)一鍵換膚效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js實(shí)現(xiàn)一鍵換膚效果的具體代碼,供大家參考,具體內(nèi)容如下

方法1

<!DOCTYPE html>
<html lang="en">
<head>
? <meta charset="UTF-8">
? <meta http-equiv="X-UA-Compatible" content="IE=edge">
? <meta name="viewport" content="width=device-width, initial-scale=1.0">
? <title>一鍵換膚</title>
? <style>
? ? :root {
? ? ? --color: white;
? ? }

? ? .card {
? ? ? width: 120px;
? ? ? height: 200px;
? ? }

? ? .controller {
? ? ? display: flex;
? ? ? justify-content: space-between;
? ? ? align-items: center;
? ? ? padding: 10px;
? ? }

? ? .btn {
? ? ? border: none;
? ? ? height: 30px;
? ? ? width: 100px;
? ? ? color: #eeeeee;
? ? ? background: linear-gradient(45deg, #ce7777, lightblue, #c19fc1, transparent);
? ? ? border-radius: 999px;
? ? ? box-shadow: 0 0 2px 2px #eeeeee;
? ? ? cursor: pointer;
? ? }

? ? .card {
? ? ? border-radius: 5px;
? ? ? box-shadow: 0 0 2px 2px rgb(126, 124, 124);
? ? }

? ? .card:nth-child(1) {
? ? ? background: black;
? ? }

? ? .card:nth-child(3) {
? ? ? background: white;
? ? }

? ? html, body {
? ? ? background: var(--color);
? ? ? opacity: 0.9;
? ? }
? ? body {
? ? ? height: 100vh;
? ? }
? ? *{
? ? ? margin: 0;
? ? ? padding: 0;
? ? }
? </style>
</head>

<body>

? <div class="controller">
? ? <div class="card"></div>
? ? <div><button class="btn" onclick="changeSkin()">一鍵換膚</button></div>
? ? <div class="card"></div>
? </div>

</body>

</html>

方法2

<!DOCTYPE html>
<html lang="en">
<head>
? <meta charset="UTF-8">
? <meta http-equiv="X-UA-Compatible" content="IE=edge">
? <meta name="viewport" content="width=device-width, initial-scale=1.0">
? <title>change skin</title>
? <style id="theme">
? ? :root {
? ? ? --bgColor: #f00;
? ? }

? ? .skin {
? ? ? background: var(--bgColor);
? ? ? width: 200px;
? ? ? height: 200px;
? ? }
? </style>
</head>

<body>
? <div class="skin"></div>
? <button type="button" onclick="changeSkin('black')">change theme</button>
? <script>
? ? changeSkin = (theme) => {
? ? ? console.log("function starts");
? ? ? document.getElementById("theme").innerHTML = `
? ? ? ? :root{--bgColor:${theme};}
? ? ? ? .skin {
? ? ? ? ? background: var(--bgColor);
? ? ? ? ? width: 200px;
? ? ? ? ? height: 200px;
? ? ? ? }
? ? ? `
? ? }
? ?
? </script>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

若羌县| 汉寿县| 灵丘县| 红原县| 泽州县| 满城县| 章丘市| 宁河县| 陆良县| 宁化县| 高雄县| 怀化市| 斗六市| 望都县| 尤溪县| 金寨县| 盈江县| 太仆寺旗| 尼勒克县| 无棣县| 称多县| 黑龙江省| 喜德县| 平江县| 轮台县| 昌宁县| 社会| 通许县| 剑川县| 观塘区| 闻喜县| 闸北区| 平果县| 武宣县| 建湖县| 东阳市| 新民市| 科技| 泸西县| 彝良县| 普安县|