# 主出口的不透明度

**URL:** <https://meta.discourse.org/t/opacity-of-main-outlet/78676>\
**Category:** Support\
**Created:** [2018年一月22日 17:29 UTC](https://meta.discourse.org/t/opacity-of-main-outlet/78676 "2018-01-22T17:29:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake\_Green](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@Jake\_Green](https://meta.discourse.org/u/Jake_Green)\
**Post date:** [2018年一月22日 17:29 UTC](https://meta.discourse.org/t/opacity-of-main-outlet/78676/1 "2018-01-22T17:29:41Z")

</div>

Hi I’ve been trying to change to opacity and colour of the main-outlet using this code:

```
#main-outlet {
background-color: rgb(60,60,60):opacity:0.6;
padding-left: 10px;
padding-right: 10px;
}

```

but it fails to work as it sets the opacity of EVERYTHING inside the main-outlet and not just the background. Thanks.

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2018年一月22日 17:45 UTC](https://meta.discourse.org/t/opacity-of-main-outlet/78676/3 "2018-01-22T17:45:43Z")

</div>

Right, by default the opacity on a parent element in CSS will apply to everything nested within.

You can avoid this by applying the opacity to the background color using an rgba (a = alpha) value. So in this case:

`background-color: rgba(60,60,60,.6);`

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2024年六月8日 12:43 UTC](https://meta.discourse.org/t/opacity-of-main-outlet/78676/4 "2024-06-08T12:43:39Z")

</div>

此主题已在 2328 天后自动关闭。不再允许回复。
