How to set image shadow in css
Setting method: 1. Use the "box-shadow: horizontal shadow vertical shadow blur spread color inset;" statement; 2. Use the "filter:drop-shadow (horizontal shadow vertical shadow blur spread color)" statement.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
There are two ways to set the shadow of an image in css:
box-shadow attribute
filter:drop-shadow( )
Let me introduce to you
1. Use the box-shadow attribute
box-shadow attribute to add to the box One or more shadows.
Syntax: box-shadow: h-shadow v-shadow blur spread color inset;
- ##h-shadow Required. The position of the horizontal shadow. Negative values are allowed.
- v-shadow Required. The position of the vertical shadow. Negative values are allowed.
- blur Optional. Fuzzy distance.
- spread Optional. The size of the shadow.
- color Optional. The color of the shadow. See CSS color values.
- inset Optional. Change the outer shadow (outset) to an inner shadow.
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style> img { box-shadow: 10px 10px 10px rgba(0, 0, 0, .5); /*考虑浏览器兼容性*/ -moz-box-shadow: 10px 10px 10px rgba(0, 0, 0, .5); -webkit-box-shadow: 10px 10px 10px rgba(0, 0, 0, .5); } </style> </head> <body> <img src="/static/imghw/default1.png" data-src="img/1.jpg" class="lazy" style="max-width:90%" / alt="How to set image shadow in css" > </body> </html>
2. Use filter:drop-shadow()# The ##filter attribute defines the visual effect (for example: blur and saturation) of the element (usually ).
drop-shadow() can set a shadow effect on the image. Shadows are composited underneath the image and can be blurred, offset versions of the matte that can be painted in a specific color.
Syntax:
filter:drop-shadow(h-shadow v-shadow blur spread color);Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style> img { -webkit-filter: drop-shadow(10px 10px 10px rgba(0, 0, 0, .5)); /*考虑浏览器兼容性:兼容 Chrome, Safari, Opera */ filter: drop-shadow(10px 10px 10px rgba(0, 0, 0, .5)); } </style> </head> <body> <img src="/static/imghw/default1.png" data-src="img/1.jpg" class="lazy" style="max-width:90%" / alt="How to set image shadow in css" > </body> </html>
(Learning video sharing:
The above is the detailed content of How to set image shadow in css. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

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)

Hot Topics

How to achieve the playback of pictures like videos? Many times, we need to implement similar video player functions, but the playback content is a sequence of images. direct...

In React projects, we often encounter problems with the use of lifecycle functions, especially when it comes to page refresh, how to ensure that certain operations only...

Regarding the problem of inconsistent width of emsp spaces in HTML and Chinese characters in many web tutorials, it is mentioned that occupying the width of a Chinese character, but the actual situation is not...

How to achieve upward scrolling loading similar to WeChat chat records? When developing applications similar to WeChat chat records, a common question is how to...

How to realize the function of playing pictures like videos? Many times, we need to achieve similar video playback effects in the application, but the playback content is not...

Using react-transition-group in React to achieve confusion about closely following transition animations. In React projects, many developers will choose to use react-transition-group library to...

1.0.1 Preface This project (including code and comments) was recorded during my self-taught Rust. There may be inaccurate or unclear statements, please apologize. If you benefit from it, it's even better. 1.0.2 Why is RustRust reliable and efficient? Rust can replace C and C, with similar performance but higher security, and does not require frequent recompilation to check for errors like C and C. The main advantages include: memory security (preventing null pointers from dereferences, dangling pointers, and data contention). Thread-safe (make sure multi-threaded code is safe before execution). Avoid undefined behavior (e.g., array out of bounds, uninitialized variables, or access to freed memory). Rust provides modern language features such as generics

How to quickly build a front-end page in back-end development? As a backend developer with three or four years of experience, he has mastered the basic JavaScript, CSS and HTML...
