How to achieve shadow effect in css

青灯夜游
Release: 2023-01-05 16:13:06
Original
26387 people have browsed it

How to achieve shadow effect in css: 1. Use the text-shadow attribute to set the text with shadow to achieve the text shadow effect; 2. Use the box-shadow attribute to apply the shadow to the text box to achieve Border shadow effect.

How to achieve shadow effect in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Method 1: Use the text-shadow attribute to achieve text shadow effect

The text-shadow attribute is used to set the text with shadow; the pixel length and width of the shadow can be set and blurred distances and shadow colors.

Example:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>css设置文本阴影效果</title> 
        <style> 
            h1 { 
                color: red; 
                text-shadow: 3px 5px 5px #656B79; 
            }
        </style> 
    </head> 
    <body> 
        <h1>文本阴影!</h1>
    </body> 
</html>
Copy after login

How to achieve shadow effect in css

Method 2: Use the box-shadow property to achieve the border shadow effect

box- The shadow attribute can apply a shadow to the text box, and can set the pixel length, width and blur distance of the shadow, as well as the color of the shadow.

Example:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>css设置边框阴影效果</title> 
        <style> 
             div{
                width:300px;
                height:100px;
                background-color:red;
                box-shadow: 10px 10px 5px #888888;
            }
        </style> 
    </head> 
    <body> 
        <div>边框阴影!</div> 
    </body> 
</html>
Copy after login

Rendering:

How to achieve shadow effect in css

(Learning video sharing: css video tutorial )

The above is the detailed content of How to achieve shadow effect in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!