256 Kilobytes

Forum in Style and Layout | By Some Guy

Published

448 views, 0 RAMs, and 1 comment

Profile Photo - Some GuySome GuyBasic Subscriber

I’ve included some of what I have already below. Basically, I want the background color to be about 50% transparent and so have applied the opacity property. However, this is making the text transparent as well! How do I get around this?

<div class="textbox">

    <p>"Hello there."</p> 
   
</div>
.textbox {
    background-color: darkorchid;
    color: black;
    border: 1px solid black;
    margin: 200px auto;
    text-align: center;
    padding: 20px; 
    max-width: 400px;
    opacity: 0.5;
}

Download more RAM. 🐏 ⨉ 0Posted by Some Guy 3 years ago 🕓 Posted at 15 December, 2018 19:19 PM PST

This is a debug account.

Profile Photo - Louis J. V. CicaleseLouis J. V. CicaleseAuthor

You can avoid setting the opacity property to the text and other elements by applying it solely to the background-color property.

The easiest way to do this is to specify the background color using the rgb color format rather than by name. You’ll use an additional alpha channel (a) at the end of this rgb value to denote opacity.

In this case I Googled the chosen color of “darkorchid” and found that the corresponding rgb value is (153, 50, 204). The “a” value at the end will be 0.5, your chosen opacity.

Here is what the rule should look like:

.textbox {
    background-color: rgba(153, 50, 204, 0.5);
}

And you can remove the "opacity: 0.5;" rule altogether.

Download more RAM. 🐏 ⨉ 0Posted by Louis J. V. Cicalese 3 years ago 🕓 Posted at 15 December, 2018 19:27 PM PST

I am Louis Cicalese, as they say.

Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account

Forum— Read More

Find more related content below!

Read More: