CSS transparency and its application for various elements
Styling elements on your own website can be undoubtedly called one of the most important tasks facing the webmaster. Here, as in life, meet on clothes. The unique style, beauty and at the same time simple and intuitive design will not only help to make a first impression, but also attract new readers, customers or customers, depending on the direction of the site.
Creating means of CSS-transparency of content, for a start it is worth understanding how it is necessary to prescribe the form itself. Of course, in this material there will be no indentation in the standard tags for programming the site page in general. For illustrative example, we will focus on a rectangular area, colored monotonous fill. To display it, you will need to create a simple CSS style file with subsequent binding, or place the code directly on the page of the html document. Having prescribed the necessary height, width, color and outline parameters for a rectangular block, you need to add code to the style that allows you to make the CSS object transparent.The parameter “opacity: 0.X” is responsible for this, as this is the level of visibility. The closer its value is to one, the object becomes invisible. This style will work properly in browsers that have support for CSS3. Almost all modern web browsers now have such instructions.
Increase code universality
If the programmer wants to optimize his content for older applications, he will need to learn additional styles.
For Internet Explorer version 5.5 and above, the perceived code is a very long and ugly line - “filter: progid: DXImageTransform.Microsoft.Alpha (opacity = X)”, where the transparency parameter should be specified not in fractions of one, but in hundreds. Its maximum value at which the transparency of the color of the CSS object becomes full is 100.
Own code exists for less popular browsers. One of these is Konqueror, better known to users of the KDE desktop on UNIX-like systems. For it, the CSS transparency will need to be set with the parameter “-khtml-opacity: 0.X”.
For complete confidence in optimizing your code, you can add a line that provides support for one of the first versions of Mozilla browsers: “-moz-opacity: 0.X”.
By performing this optimization, the webmaster can achieve the correct display of their content on most user devices.
Since CSS transparency is most often used as a design for elements with hyperlinks, hovering becomes one of the primary tasks. As an example, consider the same rectangle. Suppose it is necessary that when you hover on a block, the transparency changes from 0 to a value of 0.5. To get this opportunity, you just need to add the already existing style, which is responsible for transparency, under the additional CSS parameter hover. This property is also used to add effects such as changing the color and shape of objects when hovering. This allows you to make the necessary areas visually active, attracting the attention of visitors to the links or content.
Application for images
In the event that the process described above is clear, adding transparency to images with CSS will be easy. It does not even need to make changes to the style code itself. It can be left unchanged.You will have to work only with the layout of the pictures in the html-document itself. If in the previous cases for the insertion of the element used tags «div», here you just need to replace them with «img», corresponding to this type of content. The style for images is the same as for the blocks. Of course, applying the CSS described at the beginning of the article, you will need to change the parameters of height, width and edges for the harmonious look of the inserted image.
Text and Background Transparency
The text example is similar to inserting images. Create transparency in CSS separatelyalso not required. In this case, it will be necessary to replace the tags with those used for the layout of text fields. These are "p" and "span".
When the text is written in the body of an html document without using special tags, adding transparency will be very difficult and time consuming. Therefore, this option does not make sense to consider.
In case the website needed to make the background transparent, CSS would be the best option here. Since the background is essentially the same image or form, you just need to attach our style to it in the main code of the web resource.