Home > Web Front-end > HTML Tutorial > Tips for using box-shadow

Tips for using box-shadow

一个新手
Release: 2017-10-18 09:41:21
Original
2231 people have browsed it

1. Box-shadow parameter analysis


box-shadow:none;
Copy after login


box-shadow: h-shadow v-shadow blur spread color inset;
Copy after login
box-shadow parameter analysis
ValueDescription
noneDefault value, the element does not have any shadow effect.
h-shadowThe shadow horizontal offset, its value can be positive or negative. If the value is positive, the shadow is on the right side of the element; if it is negative, the shadow is on the left side of the element.
v-shadowThe shadow vertical offset, its value can be positive or negative. If the value is positive, the shadow is at the bottom of the element; if it is negative, the shadow is at the top of the element.
blurShadow blur radius, optional parameter. Its value can only be positive. If the value is "0", it means that the shadow has no blurring effect. If the value is larger, the edge of the shadow will be blurry.
spreadShadow expansion radius, optional parameter. Its value can be positive or negative. If the value is positive, the entire shadow will be expanded. Otherwise, if the value is negative, the entire shadow will be reduced.
colorShadow color, optional parameter. If no color is set, the browser will use the default color, but the default color is different in each browser. Especially browsers under the Webkit kernel will be colorless, that is, transparent. It is recommended not to omit this parameter.
insetShadow type, optional value. If not set, the default projection method is outer shadow; if its unique value "inset" is taken, the inner shadow is set for the element.

2. Box-shadow application

The effect we want to do next is like this

Pay attention to this area. The white box model has the border shadow of the orange box above. How to achieve this effect?


<p class="contain">
    <p class="contain-wrapper">        
    </p>
    <p class="foot-wrapper">        
    </p></p>
Copy after login

This is our html code. It is obvious that the green area is contain, the orange area is contain-wrapper, and the white area is foot-wrapper.
Let’s write their css code


*{
    margin:0;
    padding: 0;
}.contain{
    overflow: hidden;
    margin: 0 auto;
    width: 250px;
    height: 300px;
    background-color: #09b800;
}.contain-wrapper{
    margin: 0 auto;
    margin-top: 10px;
    width: 200px;
    height: 100px;
    background: #ff7e00;
    border-radius: 10px;
    box-shadow: 0px 9px 15px -1px rgba(0,0,0,0.3);
}.foot-wrapper{
    margin: 0 auto;
    width: 180px;
    height: 100px;
    background: white;
}
Copy after login

We set a border shadow for the orange box. The lower border of the orange box and the upper border of the white box are closely attached. Together, at this time, a problem arises. Let’s take a look at the effect.

#We find that the shadow of the lower border of the orange box is obscured by the white box. How can this be? good? I solved it in a very clumsy way.

Since the shadow is covered, then we let the white box compensate for giving the orange box a shadow. Isn't there a parameter called inset? Wouldn't it be great if we projected the shadow of the upper border of the white box into the inside to fill this gap?


*{
    margin:0;
    padding: 0;
}.contain{
    overflow: hidden;
    margin: 0 auto;
    width: 250px;
    height: 300px;
    background-color: #09b800;
}.contain-wrapper{
    margin: 0 auto;
    margin-top: 10px;
    width: 200px;
    height: 100px;
    background: #ff7e00;
    border-radius: 10px;
    box-shadow: 0px 9px 15px -1px rgba(0,0,0,0.3);
}.foot-wrapper{
    margin: 0 auto;
    width: 180px;
    height: 100px;
    background: white;
        box-shadow: inset 0 9px 5px -1px rgba(0,0,0,0.1);//新增,其他所有的参数要跟橙色盒子的阴影一样,只是方向改变,这样才不会影响结合起来的效果。}
Copy after login

The above is the detailed content of Tips for using box-shadow. 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