css opacity属性_CSS中的opacity属性[通俗易懂]

css opacity属性_CSS中的opacity属性[通俗易懂]cssopacity属性CSS|不透明度属性(CSS|opacityProperty)Withthegrowingneedofmakingwebsites,theneedforstylingthemhasalsoincreased.Therefore,CSShasbecomeanindispensablepartofcreating…

大家好,又见面了,我是你们的朋友全栈君。

css opacity属性

CSS | 不透明度属性 (CSS | opacity Property)

With the growing need of making websites, the need for styling them has also increased. Therefore, CSS has become an indispensable part of creating websites. Thus one must be aware of which properties to use while creating a website.

随着制作网站的需求不断增长,对网站进行样式设计的需求也越来越大。 因此,CSS已成为创建网站必不可少的部分。 因此,必须知道创建网站时要使用哪些属性。

Various properties are used for styling. Since there are so many properties to use for, it is natural for any beginner to get confused about which property to use and when.

使用各种属性进行样式设置。 由于要使用的属性太多,因此任何初学者都自然会对使用哪个属性以及何时使用感到困惑。

In this segment, the discussion will be on one such property which is known as opacity.

在这一部分中,将讨论一种称为opacity的属性。

Before implementing opacity property right away let’s first discuss this property out of the CSS’s context.

在马上实现opacity属性之前,让我们首先在CSS上下文之外讨论该属性。

不透明度属性 (opacity property)

opacity is the degree of transparency of any element living or non living. If we say that a certain object is opaque then it means that object has 0 transparency, which in turn means that no one can look through that object.

不透明性是指任何存在或不存在的元素的透明程度 。 如果我们说某个对象是不透明的,则意味着该对象的透明度为0 ,这又意味着没有人可以透过该对象查看。

And if we say that a certain object is transparent then that object has 0 opacity.

如果我们说某个对象是透明的,则该对象的不透明度为0

The same meaning of opacity holds in the CSS as well. let’s have a look!

CSS中也具有不透明度的相同含义。 我们来看一下!

Definition: As mentioned earlier the opacity is the degree of transparency. In CSS the opacity property tends to set the opacity of an element.

定义:如前所述, 不透明度是透明度。 在CSS中, opacity属性倾向于设置元素的不透明度

Degrees of Opacity:

不透明度:

  • 1 means that the object is not transparent at all.

    1表示对象根本不透明。

  • 0.5 means that the object is semi-transparent.

    0.5表示对象是半透明的。

  • 0 means that the object is entirely transparent.

    0表示对象是完全透明的。

Note: The drawback of opacity property is that if you set your elements to be transparent then all the children of attributes will also become transparent. If you want to avoid this and want to make your texts readable inside the element, then you should RGBA values instead.

注意: opacity属性的缺点是,如果将元素设置为透明的,则所有属性的子元素也将变为透明的。 如果要避免这种情况,并希望使文本在元素内可读,则应改为RGBA值

The default value of opacity is 1.

不透明度的默认值为1。

CSS Syntax:

CSS语法:

    Element{
        opacity: number|initial|inherit;
    }

Example:

例:

<!DOCTYPE html>
<html>

<head>
    <style>
        div {
   
   
            background-color: green;
            opacity: 0.55;
        }
    </style>
</head>

<body>
    <div>This following div element's opacity is 0.55</div>
    <div>The background colour is affected by the opacity level.</div>
</body>

</html>

Output

输出量

CSS | opacity property example

In the above example, the opacity level of 0.55 is applied to the div element.

在上面的示例中,将不透明度级别0.55应用于div元素。

Value Description
number This specifies the opacity from 0.0 ( transparent) to 1.0 ( opaque).
initial This sets this property to its default value.
inherit Helps in inheriting this property from its parent element.
描述
这将不透明度指定为0.0(透明)到1.0(不透明)。
初始 将此属性设置为其默认值。
继承 帮助从其父元素继承此属性。

Conclusion:

结论:

When it comes to using opacity property one should be very considerate in using it as given its drawback this property can also make your sub-elements opaque as well.

在使用不透明度属性时,应谨慎使用它,因为它的缺点是该属性也会使子元素也变得不透明。

opaque property is a very good tool when it comes to styling pictures. So have fun using it!

对于图片样式, 不透明属性是一个非常好的工具。 祝您使用愉快!

翻译自: https://www.includehelp.com/code-snippets/opacity-property-in-css.aspx

css opacity属性

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/141184.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 一些常用单位之间的换算

    一些常用单位之间的换算一些常用单位之间的换算单位表格汇总单位表格汇总请注意下方的表格:目前只对链接(也就是文字颜色有变换的那个)产生了单位的换算,其他的没有做换算,如果有清楚的可以在本篇博文下留言,正确的留言单位换算就打算加上链接,错误的就请大家帮忙纠正一下,感谢各位配合!!!常用物理量的名称、符号和单位名称…

    2022年5月14日
    172
  • vista系统改xp_男生隔一小时才回信息

    vista系统改xp_男生隔一小时才回信息昨天装了vista,挺激动的。平时都是在虚拟机上运行vista,重来没见过玻璃效果。并且使用VistaLoaderV2.1.2成功激活(这种方法即不用刷bios,也不用改什么系统文件)用了vista确实是够漂亮,但内存消耗超过700Mb,系统占了硬盘超过7g 。真是佩服M$!!它真pc当成超级计算机啦。最糟糕的uac实在是让人崩溃。看来vista最大的敌人是xp了。

    2022年10月12日
    6
  • 如何解决Mac上网速度很慢的问题(多种可能分析)[通俗易懂]

    如何解决Mac上网速度很慢的问题(多种可能分析)[通俗易懂]问题:我发现在我的Mac上上网的速度很慢。第一种分析:问题分析:虽然Mac上的运行速度很慢,但同时在我的两台手机上面的运行速度都比较快。我刚开始怀疑是路由器的问题,如果是路由器的问题,那么手机肯定不会很块,手机也会很慢,可以断定肯定是我的mac设置出了问题,我按个这个步骤寻找,去掉8.8.8.8,问题解决了。将上面的DNS地址8.8.8.8去掉就好了分析8.8.8……

    2025年11月7日
    2
  • java io常用类总结

    java io常用类总结读写数据是java开发过程中经常需要做的,本篇文章将我们平时常用的javaio处理类做个总结,同时给出相关demo。可以看得出来,JAVAIO主要有这四个类InputStream、OutputStream、Reader、Writer来处理,要处理字节流的就用InputStream、OutputStream,要处理字符流,就用Reader、Writer,现实中根据需要,我们选择他们的相关子类进行…

    2022年5月9日
    42
  • 用python爬虫爬取网页信息_爬虫python

    用python爬虫爬取网页信息_爬虫python【一、项目背景】[蜜柑计划-MikanProject]:新一代的动漫下载站。是一个专门为喜欢动漫的小伙伴们打造的动漫视频在线播放网站,为大家第一时间分享最新动漫资源,每日精选最优质的动漫推荐。【二、项目目标】实现获取动漫种子链接,并下载保存在文档。【三、涉及的库和网站】1、网址如下:https://mikanani.me/Home/Classic/{}2、涉及的库:reques**ts、lxml、fake_useragent**3、软件:PyCharm【四、项目分析】…

    2022年10月21日
    3
  • python drawcontours_2021-02-15 Python OpenCV drawContours()函数

    python drawcontours_2021-02-15 Python OpenCV drawContours()函数drawContours image contours contourIdx color thickness 1 lineType LINE 8 hierarchy noArray maxLevel INT MAX offset None 该函数用于绘制轮廓线或者填充轮廓线 如果参数 那么就绘制轮廓线 如果参数 则填充轮廓线内的区域 参数 image 目标图像 contour

    2025年8月30日
    7

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号