HTML不透明度属性与CSS不透明度 [英] HTML opacity attribute vs CSS opacity
问题描述
我知道在HTML中设置不透明度的两种不同方式:
I know of two different ways of setting opacity in HTML:
< div opacity ="0.5"></div>
和
< div style ="opacity:0.5;"></div>
我也知道如何在JavaScript中设置这两个参数:
I also know how to set both of those in JavaScript:
div.setAttribute("opacity",0.5);
和
div.style.opacity = 0.5
这两种方法之间是否有主要区别?我应该优先选择另一个吗?(我想我至少应该保持一致)
Are there any major differences between those two methods? Should I prefer one over the other? (I guess I should at least be consistent)
推荐答案
我知道的唯一的 示例元素
以下元素可以使用opacity属性 The following elements can use the opacity attribute 图形元素 [和] 您的 Your 这篇关于HTML不透明度属性与CSS不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! opacity
属性是< a>
< defs>
<字形>
< g>
< marker>
< missing-glyph>
< pattern>
< svg>
< switch>
< symbol>
< div opacity ="0.5"></div>
在HTML中不起作用,因此,要设置HTML元素的样式,应使用CSS控制不透明度.<div opacity="0.5"></div>
doesn't work in HTML and therefore, to style HTML elements, opacity should be controlled with CSS.