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月26日 下午1:40
下一篇 2022年5月26日 下午2:00


相关推荐

  • C++ 简单FTP客户端软件开发

    C++ 简单FTP客户端软件开发题目简单 FTP 客户端软件开发 100 分 网络环境中的一项基本应用就是将文件从一台计算机中复制到另一台可能相距很远的计算机中 而文件传送协议 FTP 是因特网上使用得最广泛的文件传送协议 FTP 使用客户服务器方式 设计要求 1 以命令行形式运行 2 该 FTP 客户端程序具有以下基本功能 能完成 FTP 链接的打开和关闭操作 能执行文件的上传和下载 能完成目录的创建 删除等有关操作 3 设计中加入新的功能 登录 进入上级或下级目录要求可以传输简单的文本文件 设计思路 1 分为两个端口 指令交流端口 数据交换端

    2026年3月26日
    6
  • pycharm英语怎么读_pycharm快捷键翻译「建议收藏」

    pycharm英语怎么读_pycharm快捷键翻译「建议收藏」翻译英语中文德语检测语言中文(简体)英语日语源语言:马耳他语———————–页面1———————–PyCharm默认的键盘对应PyCharm默认的键盘对应PyCharm默认的键盘对应编辑运行使用搜索按Ctrl+空格Basic代码完成(或任何类别,方法ALT+SHIFT+F10选择的配置和运行ALT+F7/按Ctrl+…

    2022年8月25日
    8
  • 微信小程序 父子组件传值通信

    微信小程序 父子组件传值通信微信小程序父组件往子组件传值:父:&lt;getCodephone="{{phone}}"bind:myevent="onGetCode"&gt;&lt;/getCode&gt;通过phone=”{{phone}}”传向子组件子:properties:{phone:{//属性名type:Number,…

    2022年5月17日
    125
  • 16天记住7000考研英语单词_最难记的考研单词

    16天记住7000考研英语单词_最难记的考研单词

    16天记住7000考研单词(第九天)
    401.Thebelovednovelistputherlovelyglovesabovethestove.
    敬爱的小说家把她美丽的手套放在火炉上方。
    402.It’sprovedthattheapproverimprovedwaterproofroof.
    经证实,赞同者改善了防水屋顶.
    403.Inthereaction,thefractionac

    2022年8月24日
    10
  • 最全CSS3实现水平垂直居中的10种方案

    最全CSS3实现水平垂直居中的10种方案最全的实现水平垂直居中方案

    2026年3月19日
    2
  • Windows核心编程第五版pdf

    Windows核心编程第五版pdf下载地址 网盘下载图书简介 编辑这是一本经典的 Windows 核心编程指南 从第 1 版到第 5 版 引领着数十万程序员走入 Windows 开发阵营 培养了大批精英 作为 Windows 开发人员的必备参考 本书是为打算理解 Windows 的 C 和 C 程序员精心设计的 第 5 版全面覆盖 WindowsXP WindowsVista 和 WindowsServe 中的 17

    2026年3月17日
    1

发表回复

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

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