我们可以从子类型设置父元素样式吗? [英] Can we set parent element style from child style?
本文介绍了我们可以从子类型设置父元素样式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div id="main">
<div id="sub">
</div>
</div>
我可以从sub的风格设置main的样式吗?
Can I set main's style from sub's style?
推荐答案
级联样式表只是(级联)下降,所以它们不是设计成这样做的...即使在极少数情况下, em> handy如果他们做到了。
Cascading Stylesheets only go (cascade) down, so they're not designed to do this at all...even in those rare cases it would be very handy if they did.
您需要使用JavaScript,内嵌样式或不同的布局来获取您以前的样子...但是影响父级的纯CSS不是一个选项这里很不幸。
You need either JavaScript, in-line style or a different layout to get the stying you're after...but pure CSS affecting the parent isn't an option here unfortunately.
这篇关于我们可以从子类型设置父元素样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文