How To Upload An Image With A Transparent Background Html Css
CSS Opacity / Transparency
The opacity
property specifies the opacity/transparency of an chemical element.
Transparent Epitome
The opacity
property tin take a value from 0.0 - 1.0. The lower value, the more transparent:
opacity 0.two
opacity 0.5
opacity i
(default)
Transparent Hover Effect
The opacity
property is often used together with the :hover
selector to change the opacity on mouse-over:
Example explained
The start CSS cake is like to the lawmaking in Example ane. In addition, we take added what should happen when a user hovers over one of the images. In this case we desire the image to NOT be transparent when the user hovers over information technology. The CSS for this is opacity:one;
.
When the mouse arrow moves away from the epitome, the image will be transparent once again.
An case of reversed hover effect:
Transparent Box
When using the opacity
property to add transparency to the groundwork of an element, all of its child elements inherit the aforementioned transparency. This can make the text inside a fully transparent element hard to read:
Transparency using RGBA
If you do not desire to utilize opacity to child elements, like in our example above, use RGBA color values. The following example sets the opacity for the groundwork colour and non the text:
You learned from our CSS Colors Chapter, that yous can use RGB as a color value. In addition to RGB, y'all can use an RGB color value with an blastoff channel (RGBA) - which specifies the opacity for a color.
An RGBA color value is specified with: rgba(red, green, blue, blastoff). The blastoff parameter is a number between 0.0 (fully transparent) and ane.0 (fully opaque).
Tip: You volition learn more than about RGBA Colors in our CSS Colors Affiliate.
Example
div {
background: rgba(76, 175, 80, 0.3) /* Green background with xxx% opacity */
}
Try information technology Yourself »
Text in Transparent Box
This is some text that is placed in the transparent box.
Example
<html>
<head>
<style>
div.background {
background: url(klematis.jpg) echo;
edge: 2px solid black;
}
div.transbox {
margin: 30px;
groundwork-color: #ffffff;
border: 1px solid black;
opacity: 0.six;
}
div.transbox p {
margin: 5%;
font-weight: bold;
color: #000000;
}
</style>
</head>
<body>
<div class="background">
<div grade="transbox">
<p>This is some text that is placed in the transparent box.</p>
</div>
</div>
</body>
</html>
Endeavour it Yourself »
Example explained
Kickoff, we create a <div> element (class="background") with a background image, and a border.
Then we create another <div> (class="transbox") inside the first <div>.
The <div class="transbox"> have a background color, and a border - the div is transparent.
Inside the transparent <div>, we add some text inside a <p> element.
Source: https://www.w3schools.com/css/css_image_transparency.asp
Posted by: lopezproffecanded.blogspot.com
0 Response to "How To Upload An Image With A Transparent Background Html Css"
Post a Comment