The element's translucency effect is clearly visible in the background image and has become widespread in various operating systems because it looks stylish and beautiful. In web design, translucency is also used and achieved through the opacity property or the RGBA color format that is set for the background.
opacity property
The main feature of this property is that the transparency value affects all child elements inside, not just the background. This means that both the background and the text will become translucent and it will not work to increase the transparency level by adding . In table. 1 shows the appearance of text and background with different opacity values.
Example 1 shows how to create a translucent box using opacity .
Example 1: Background on a web page
HTML5 CSS3 IE 9+ Cr Op Sa Fx
RGBA
Usually, by design, only the background of the element should be translucent, and the text should be opaque to preserve its readability. The opacity property doesn't fit here because the text inside the element will also be partially transparent. It is best to use the RGBA format, of which the alpha channel, or in other words the transparency value, is a part. The value is written rgba , then the values of the red, blue and green components of the color are listed in parentheses separated by commas. Last comes transparency, which is set from 0 to 1 (Fig. 1), while 0 means full transparency, and 1 means opacity of the color.
Rice. 1. Syntax of using rgba
Example 2 shows the use of the RGBA format to create a translucent background.
Example 2: Semi-transparent background
HTML5 CSS3 IE 9+ Cr Op Sa Fx
The result of this example is shown in Fig. 2. Opacity value for the background is set to 90%.
Rice. 2. Semi-transparent background and opaque text
Quite often, you can find a suitable image on the Internet, for example, to insert it on a website. Or perhaps you are making a collage, and you need to add others to one picture. That's just the desired images usually have some kind of background.
Let's see how we can make a transparent background for the image using the editorAdobephotoshop. I have the English version of Adobe Photoshop CS5 installed, so I will show it on it.
I will try to give various combinations of hot keys.
If you do not have Photoshop installed yet, you rarely use it, or it is in English, you can make a transparent background in Paint.net. This is a simple Russian-language image editor that will not take up much space on your hard drive. By clicking on the link, you can read the detailed article. You can download the Paint.net program from our website.
Let's start with a simple example. Suppose you have an image on a plain background, it can be a logo or the name of something. Let's make this logo or inscription on a transparent background in Photoshop.
Open the desired image in the editor. Now let's make a transparent background for the layer. In the "Layers" window, double-click on the added layer - there will be a lock opposite it. A New Layer window will open, click OK. After that, the lock will disappear.
Select the Magic Wand tool. In the property bar, specify the sensitivity level, set different values to understand how it works, for example, 20 and 100. To deselect the picture, press "Ctrl + D".
Set the sensitivity and press the magic wand on the background area. To add to the selected background, those parts that are not selected, hold down "Shift" and continue the selection. To delete selected areas, click "Delete".
Now, instead of a background, a chessboard - this means that we managed to make the white background transparent. Remove the selection - "Ctrl + D".
If you have an image or photo that has a lot of different colors and objects, let's look at how to make a transparent background for an image in Photoshop.
In this case, we will use the Quick Selection tool. We click on the magic wand with the left mouse button with a slight delay and select the desired tool from the menu.
Now we need to select the object that we want to leave on a transparent background. In the property bar, set different sizes and click on the object, adding areas to it. If an unnecessary background is mistakenly highlighted, press "Alt" and remove it.
Press "Q" to view the result. The parts of the image that become transparent will be highlighted in pink.
Copy the selected areas by pressing "Ctrl + C". Next, create a new file, "Ctrl + N", with a transparent background.
Paste the copied fragments into it, "Ctrl + V". If there are unnecessary parts of the background on them, remove them using the Eraser tool. We save images made on a transparent background in PNG or GIF format.
Make the white background of a picture transparent, or make a transparent background for individual fragments of a color image or photo in Photoshop. After that, you can use them where necessary: paste them on the site, add them to another picture, or make interesting collages.
CSS Background Transparency
The transparency of the background on the site is created through CSS properties. There are two ways to achieve transparency: through the opacity property and background:rgba(). Let's look at each of them, and then make a comparison.
1. CSS opacity property for background transparency
CSS has an opacity property with which you can set the transparency of images, texts, including backgrounds.
Transparency is specified simply by specifying a real number between 0.0 and 1.0. The lower the number, the less visible the object will be.
opacity: 0.5 // translucency opacity: 0.2; // The object is only visible at 20% opacity: 0.8; // Object is only 80% visible
Let's look at an example with the opacity property.
The text is also transparent