gpt4 book ai didi

javascript - 根据其他类的 css 样式操作类的 css 样式

转载 作者:行者123 更新时间:2023-11-28 17:28:01 24 4
gpt4 key购买 nike

我在我的混合应用程序上使用 Framework7 插件的抽屉导航。可以使用按钮打开/关闭抽屉,也可以使用向左/向右滑动/滑动。

现在当抽屉导航打开时,类 <div class="panel panel-left panel-reveal">添加了另一个类 active类(class)。所以当打开时:<div class="panel panel-left panel-reveal active ">关闭时:<div class="panel panel-left panel-reveal>

基于该事件,是否可以将样式添加到其他类?例子是这个类:<div class="views"><div class="views" style="opacity: 0.5">

完成什么当抽屉打开时,类view将添加样式,当抽屉关闭时删除 view类(class)作风。

是否有可能捕捉到该事件并完成我想做的事情?

最佳答案

Sorry for the delay, so below is the sample code to add a css class to a div only on hover event. I have done this using html and css only. (No DOM manipulation).

<!doctype html>
<html>
<head>
<style>
a.ex1:hover{color: red;}
a.ex2:hover, a.ex2:active {font-size: 150%;}
a.ex3:hover, a.ex3:active {background: red;}
a.ex4:hover, a.ex4:active {font-family: monospace;}
a.ex5:visited, a.ex5:link {text-decoration: none;}
a.ex5:hover, a.ex5:active {text-decoration: underline;}
.open-close{ display: none;}
a.ex6:hover .open-close{display: block;}
</style>
</head>
<body>
<p>
<a class = "ex1" href="#"> This link changes color </a>
</p>
<p>
<a class = "ex2" href="#"> This link changes font-size </a>
</p>
<p>
<a class = "ex3" href="#"> This link changes background-color </a>
</p>
<p>
<a class = "ex4" href="#"> This link changes font-family </a>
</p>
<p>
<a class = "ex5" href="#"> This link changes text-decoration </a>
</p>
<p>
<a class = "ex6" href="#">
<div>This link displays another div by detecting change in class</div>
<div class="open-close">
Here you can add your content to hide/show/modify elements based on the classes
</div>
</a>
</p>
</body>
</html>

NOTE - Just remember to use the appropriate CSS selector based on your HTML structure.

Hope this helps. Let me know if you have any questions. Happy to help.

关于javascript - 根据其他类的 css 样式操作类的 css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38606270/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com