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:- Enable Versioning on SharePoint Online Site Task List - SharePoint
- How to take a screenshot on Microsoft Windows OS on PC or Laptop - Microsoft
- Java: How to Add two Maps with example - Java
- [Fix] Connect to Minecraft Remote Connect URL via https //aka.ms/remoteconnect - Microsoft
- Convert text to random case using Notepad++ - NotepadPlusPlus
- Annual Surveys that Software Developers Should Look for! - News
- Delete Android Studio Projects - Android-Studio
- Save TextEdit file as a PDF - MacOS