There are many ways in which we can set the background of an element in HTML Opaque using CSS. Let's take a look at a few examples.
Example 1: Opacity Property
<div class="div-opaque-05">Opacity 0.5</div>
<div class="div-opaque-08">Opacity 0.8</div>
<style>
.div-opaque-05 {
background-color: #000;
opacity: 0.5;
color: #fff;
padding:10px
}
.div-opaque-08 {
background-color: #000;
opacity: 0.8;
color: #fff;
padding:10px
}
<style>
Opacity 0.5
Opacity 0.8
Example 2: Using Hex Color Code Alpha Channel
.div-opaque-05 {
background-color: #00000080;
color: #fff;
padding:10px
}
.div-opaque-08 {
background-color: #00000050;
color: #fff;
padding:10px
}
Example 3: Using RGBA Background Color
.div-opaque-05 {
background-color: rgba(0, 0, 255, 0.3);
color: #fff;
padding:10px
}
.div-opaque-08 {
background-color: rgba(0, 0, 255, 0.8);
color: #fff;
padding:10px
}
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to CSS,
- How to create a circular Image using pure CSS Code
- Horizontally Center Align tag in HTML using CSS
- Add scroll to div element in HTML Css
- Change CSS Background Opacity with Examples
- How to make text bold using CSS
- How to place two div elements next to each other
- Vertically Center Text in a DIV Element
- align image at middle of div element
- Tailwind CSS Hello World Example
- How to make div or text in html unselectable using CSS
- Only Chessboard using HTML and CSS Code Example
- Simple CSS Grid Example
- How to set CSS background-Image Property
- CSS Background Opacity with Examples
- reCAPTCHA Implementation Tutorial
- List of 32 CSS cursors web developers must know about
- How to Vertically Center Align Text in a Div using CSS Code Example
- 10 Must Know CSS Border Styles with Examples
- Tutorial : Simple Lightweight Pure CSS based Vertical Navigation Menu
- CSS: Apply opacity only for div background and not text
- Set Falling Show on Website for Christmas using Pure CSS Code
- How to make jsfiddle bootstrap ready
- Elegant CSS Box Shadows Ideas
- Responsive Web Design with CSS Media Queries: A Beginner's Tutorial [Updated for 2023]
- How to Center Align Image in Bootstrap
More Posts:- 🌗 List of Solar Eclipses in the year 2020-2021 🌑 - Science
- How to Remove Widgets from macOS Sonoma 14 Desktop - MacOS
- Fix - zsh: permission denied: ./gradlew [Android Studio Terminal] - Android-Studio
- Android Emulator window was out of view and was recentered - Android-Studio
- [Solution] Mac Update Stuck Preparing macOS Ventura 13.0 About 30 minutes remaining - MacOS
- [Fix] Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range - Java
- Hide Navigation Bar from Android Screen Activity - Android
- Writing your first Hello, World! 🌍 JavaScript code Tutorial - JavaScript