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

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

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

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

方法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>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

乌拉特中旗| 珲春市| 雅江县| 民县| 华安县| 阳江市| 邢台市| 陵水| 淳安县| 海兴县| 呼伦贝尔市| 江西省| 兴和县| 大英县| 清远市| 大埔区| 阳泉市| 金川县| 兴城市| 潮安县| 汽车| 平原县| 古蔺县| 鄯善县| 桦南县| 安图县| 延长县| 安阳县| 扎鲁特旗| 黔江区| 江山市| 石棉县| 洞口县| 开化县| 惠东县| 北海市| 德阳市| 通化市| 南安市| 拉萨市| 龙胜|