Sections of the site
Editor's Choice:
- How to install Windows on Mac?
- Asus rt n16 setup firmware
- How to find out the bitness of the operating system and processor in Windows
- How to turn off the Windows Firewall: complete deactivation and disabling for individual programs How to completely disable the Windows 7 firewall
- Powerful converter of HTML files to Doc, PDF, Excel, JPEG, Text Using the Total HTML Converter program
- How to remove headers and footers in Excel How to make a header and footers in Excel
- Design and principle of operation
- Create a portrait from a font using Photoshop Portraits from letters
- History of the device
- How to reinstall a program on your computer How to reinstall a game without deleting it
Advertising
CSS transparency is a cross-browser solution. CSS opacity property: managing transparency How to make it work in all browsers |
Sometimes there is a need to make a transparent background for a certain block on the page. This effect can be achieved by creating a transparent background image in *.png format and setting it through the background property: url(“./images/fon.png”); . Using the OPACITY propertyWhy such complexity if it can be done with using CSS. Let's create a main block (page) and a nested block (block) on the page, to which we will set transparency. Cross-browser compatibility is achieved as follows: property for Internet Explorer– filter:alpha(opacity=50) ( transparency value ranging from 0 to 100), for browsers that support the CSS3 standard – opacity:0.5 ( number ranging from 0.0 to 1.0). HTML code: Semi-transparent element div.page ( margin:0 auto; width:450px; height:300px; background:url(../images/3a0fdf3dc1.jpg) no-repeat; border:2px solid #555555 ) div.block ( width:260px ; height:140px; margin-left:94px; border:1px solid #333333; */ opacity:0.5 ) div.block p ( margin:47px 0 0 10px; font-weight:bold; color:#000000; text-align: center; ) Transparent background for the block. Result : Transparent background for the block As you noticed, transparency applies to all child elements Transparent background for the block in DIVs with class block and they cannot exceed the transparency value of their parent. That is, everything that is in this block becomes transparent. What to do if you need to leave a transparent background only for the div? Using the BACKGROUND-COLOR propertyWe need to make some changes to the CSS style sheet, namely, replace the opacity property for the DIV with the block class with the background-color property. Div.block ( width:260px; height:140px; margin-top:79px; margin-left:94px; border:1px solid #333333; /* transparent background only DIV.block */ background-color: rgba(255, 255 , 255, 0.5); /* Background color, transparency 0.5*/ ) Result : Transparent background for the block In the above example it is used for color and background RGBA format. Where, the first three letters stand for red, green, blue (red, green, blue), the last symbolizes the alpha channel (a) and specifies transparency b element from 0.0 before 1.0 . Background-color: rgba(r, g, b, a); The value of the color component is placed in parentheses instead of letters; it can be viewed in any graphic editor, for example Paint.Net (screenshot). The last value of a sets the transparency and is the same as the value of the opacity property. http://cp77.comxa.com/verstka/css-transparent-fon The opacity CSS property sets the opacity of an element. Opacity is the degree to which content is hidden behind an element, and is the opposite of transparency. The source for this interactive example is stored in a GitHub repository. If you"d like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. opacity applies to the element as a whole, including its content, even if the value is not inherited by child elements. This way, the element and its children have the same opacity relative to the element's background, even if they have different opacity relative to each other. Using opacity with a value other than 1 places the element in a new overlay context. Examples Basic example div ( background-color: yellow; ) .light ( opacity: 0.2; /* Text is barely visible against the background */ ) .medium ( opacity: 0.5; /* Text is more visible against the background */ ) .heavy ( opacity: 0.9; /* The visibility of the text is very clear against the background */ ) You can barely see this. This is easier to see. This is very easy to see. Different opacity with:hover img.opacity ( opacity: 1; filter: alpha(opacity=100); /* IE8 and below */ zoom: 1; /* "hasLayout" triggers in IE 7 and below */ ) img.opacity :hover ( opacity: 0..png" alt="MDN logo" width="128" height="146" class="opacity"> Проблемы доступности !}If text opacity is adjusted, it is important to ensure that the contrast ratio between the color of the text and the background on which the text is placed is high enough so that people with low vision can read the contents of the page. The color contrast ratio is determined by comparing the brightness of the text with the adjusted opacity and background color value. To comply with current Web Content Accessibility Guidelines (WCAG), text content requires a ratio of 4.5:1 and 3:1 for larger text such as headings. Large text is defined as 18.66px or larger, or 24px or larger. Specifications
The compatibility table on this page is generated from structured data. If you"d like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. Update compatibility data on GitHub
Good day, web development geeks, as well as newbies. For those who do not follow IT trends, or rather web fashion, I would like to solemnly inform you that this publication is on the topic: “How to make a transparent block css tools» just in time for you. Indeed, in the current 2016, the introduction of various transparent objects into online services is considered a stylish move. Therefore, in this article I will tell you about all existing methods of creating transparency, starting from antediluvian solutions, I will focus on the compatibility of solutions with browsers, and also give specific examples program code. Now let's get to work! Method 1. AntediluvianWhen were there still weak computers and “abilities” are not developed, developers came up with their own way of creating transparent background: Use transparent pixels alternately with colored pixels. The block created in this way looked like a chessboard when scaled, but at normal size it resembled some kind of transparency. This, in my opinion, “crutch” certainly helps out in older versions of browsers in which modern solutions do not work. But it is worth noting that the quality of display of text entered into such a format drops sharply. Method 2. Not botheredIn rare cases, developers solve the problem of introducing a translucent image by inserting... a ready-made translucent image! For this purpose, images saved in PNG-24 format are used. The graphic format allows you to set 256 levels of translucency.
|