How to set image transparency in css
In CSS, you can use the opacity attribute to set the transparency of the image. The syntax is "opacity: value", where the value range is between "0.0-1.0"; when the value is 1, it means completely opaque, when the value is A value of 0.5 represents translucence, and a value of 0 represents complete transparency.
The operating environment of this tutorial: Windows7 system, CSS3&&HTML5 version, Dell G3 computer.
Picture transparency setting
.opacity img{opacity: 0.5;}
The code and effect pictures are as follows.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> body { background:url(../images/bg.jpg) no-repeat; } .opacitybox{ width: 400px; height: 200px; margin:0 auto; margin-top:320px; } .opacity img{ opacity: 0.5; } </style> </head> <body> <div class= "opacitybox opacity"> <img src="/static/imghw/default1.png" data-src="../images/img.jpg" class="lazy" alt="" style="max-width:90%"> </div> </body> </html>
Recommended learning: css video tutorial
The above is the detailed content of How to set image transparency in css. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

TheCSSfilterpropertyallowsvisualeffectslikeblur,brightness,andgrayscaletobeapplieddirectlytoHTMLelements.1)Usethesyntaxfilter:filter-function(value)toapplyeffects.2)Combinemultiplefilterswithspaceseparation,e.g.,blur(2px)brightness(70%).3)Commonfunct

To change the CSS list style, first use list-style-type to change the bullet or numbering style. 1. Use list-style-type to set the bullet of ul to disc, circle or square, and the number of ol is decimal, lower-alpha, upper-alpha, lower-roman or upper-roman. 2. Remove the tag completely with list-style:none. 3. Use list-style-image:url('bullet.png') to replace it with a custom image. 4. Use list-style-position:in

When using CSS selectors, low-specific selectors should be used first to avoid excessive limitations; 1. Understand the specificity level and use them reasonably in the order of type, class, and ID; 2. Use multi-purpose class names to improve reusability and maintainability; 3. Use attributes and pseudo-class selectors to avoid performance problems; 4. Keep the selector short and clear scope; 5. Use BEM and other naming specifications to improve structural clarity; 6. Avoid the abuse of tag selectors and:nth-child, and give priority to the use of tool classes or modular CSS to ensure that the style is controllable for a long time.

Use a div with border to quickly create vertical lines, and define styles and heights by setting border-left and height; 2. Use ::before or ::after pseudo-elements to add vertical lines without additional HTML tags, suitable for decorative separation; 3. In Flexbox layout, by setting the width and background color of the divider class, adaptive vertical dividers between elastic containers can be achieved; 4. In CSSGrid, insert vertical lines as independent columns (such as autowidth columns) into grid layout, which is suitable for responsive design; the most appropriate method should be selected according to the specific layout needs to ensure that the structure is simple and easy to maintain.

Use CSS to create dotted borders, just set the border attribute to dotted. For example, "border:3pxdotted#000" can add a 3-pixel-wide black dot border to the element. By adjusting the border-width, the size of the point can be changed. The wider borders produce larger points. You can set dotted borders for a certain side, such as "border-top:2pxdottedred". Dotted borders are suitable for block-level elements such as div and input. They are often used in focus states or editable areas to improve accessibility. Pay attention to color contrast. At the same time, different from dashed's short-line style, dotted presents a circular dot shape. This feature is widely used in all mainstream browsers.

It is feasible to create a responsive automatic carousel slider with pure CSS, just combine HTML structure, Flexbox layout, and CSS animation. 2. First build a semantic HTML container containing multiple recommendation terms, each .item contains reference content and author information. 3. Use the parent container to set display:flex, width:300% (three slides) and apply overflow:hidden to achieve horizontal arrangement. 4. Use @keyframes to define a translateX transformation from 0% to -100%, and combine animation: scroll15slinearinfinite to achieve seamless automatic scrolling. 5. Add media

Useaflexiblecontainerwithheight:100vhormin-heightandbackground-size:covertoensuretheherosectionfillstheviewportwhilemaintainingimageaspectratio.2.PlacecenteredcontentusingFlexboxorplace-items:centerinCSSGridforverticalandhorizontalalignment.3.Maketex

Usebuilt-incursortypeslikepointer,help,ornot-allowedtoprovideimmediatevisualfeedbackfordifferentinteractiveelements.2.ApplycustomcursorimageswiththecursorpropertyusingaURL,optionallyspecifyingahotspotandalwaysincludingafallbacklikeautoorpointer.3.Fol
