/*html代码*/
<div class="test"></div>


/*对应的css代码*/
.test{
	width: 100px;
	height: 100px;
	background: yellow;
	margin: 100px auto;
	border-radius: 50%;
	box-shadow: 10px 10px 20px 10px rgba(255,255,0,0.5), -10px 10px 10px 10px rgba(255,255,255,0.5)
}
/*核心代码*/
.active{
box-shadow: inset 0px 0px 16px 0px rgba(0, 145, 255, 1);
}
box-shadow: h-shadow v-shadow blur spread color inset;
text-shadow:h-shadow  v-shadow  blur  color;
box-shadow: h-shadow v-shadow blur spread color inset;
box-shadow: inset 8px 8px 16px #90bac7,inset -8px -8px 12px #c3f0ff;
这两种都是PS图层样式的投影效果,不同的是,一个阴影显示在外,一个显示在内
说具体点,以图片的边缘为界,'投影'是显示在边缘外的阴影,'内阴影'是显示在边缘内的阴影
<!DOCTYPE html>
<html>
<head>
    <style>
        p.one {
            text-shadow: 3px 5px 5px #FF0000;
        }
        p.two {
            color: white;
            text-shadow: 1px 1px 2px black,
                         0 0 25px blue,
                         0 0 5px darkblue;
        }
    </style>
</head>
<body>
    <p class="one">文本阴影效果</p>
    <p class="two">文本阴影效果</p>
</body>
</html>
.class{//你的class
    box-shadow:4px 6px 5px rgb(126, 123, 123);
}
.shadow {
    -moz-box-shadow: 3px 3px 4px #000;
    -webkit-box-shadow: 3px 3px 4px #000;
    box-shadow: 3px 3px 4px #000;
    /* For IE 8 */
    -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";
    /* For IE 5.5 - 7 */
    filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000');
}
-webkit-box-shadow:0px 3px 3px #c8c8c8 ;
-moz-box-shadow:0px 3px 3px #c8c8c8 ;
box-shadow:0px 3px 3px #c8c8c8 ;
1. .box-shadow{  
2.   
3. 4.0-  
4.   
5.          -moz-box-shadow:投影方式 X轴偏移量 Y轴偏移量阴影模糊半径 阴影扩展半径 阴影颜色;  
6.   
7. 10.0-  
8.   
9.          -webkit-box-shadow:投影方式 X轴偏移量 Y轴偏移量阴影模糊半径 阴影扩展半径 阴影颜色;  
10.   
11. 4.0+、 Google chrome 10.0+ 、 Oprea10.5+ and IE9  
12.   
13.          box-shadow:  投影方式 X轴偏移量 Y轴偏移量 阴影模糊半径 阴影扩展半径 阴影颜色;  
14.   
15. }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>文本阴影</title>
<style>h1{
/*文本阴影,参数分别为:水平距离,垂直距离,模糊距离,阴影颜色*/
text-shadow: 5px 5px 2px aqua;
}</style>
</head>
<body>

<h1>标题</h1>

</body>
</html>
<!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>* {
margin: 0;
}

div {
width: 100px;
height: 100px;
background: linear-gradient(45deg,red,blue);
}</style>
</head>

<body>
<div></div>
</body>

</html>
-webkit-box-shadow:0px 3px 3px #c8c8c8 ;
-moz-box-shadow:0px 3px 3px #c8c8c8 ;
box-shadow:0px 3px 3px #c8c8c8 ;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>盒子阴影</title>
<style>div{
width: 300px;
height: 300px;
margin-left: 20px;
margin-top: 20px;
border: 10px solid yellow;
background-image: url("../resource/image/img.png");
background-size: cover;
/*box-shadow:水平位置,垂直位置,模糊距离,阴影尺寸,阴影颜色,inset*/
box-shadow: 20px 20px 100px 10px yellow;
}</style>
</head>
<body>

<div></div>

</body>
</html>
/* 创建一个名为shadow的CSS类 */
.shadow {
    -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.5), 10, 0, 0, 0);
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="160dp"
                android:scaleType="centerCrop"
                android:src="@drawable/balon" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="16dp">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:text="@string/card_title"
                    android:textColor="#000"
                    android:textSize="18sp" />
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/card_content"
                    android:textColor="#555" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/action_share"
                    android:theme="@style/PrimaryFlatButton" />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/action_explore"
                    android:theme="@style/PrimaryFlatButton" />
            </LinearLayout>
        </LinearLayout>
    </android.support.v7.widget.CardView>
</RelativeLayout>复制代码
public class ShadowView extends View {
    private Paint mShadowPaint;
    private Drawable mBackgroundDrawable;

    public ShadowView(Context context) {
        super(context);
        init();
    }

    public ShadowView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        // 初始化阴影画笔
        mShadowPaint = new Paint();
        mShadowPaint.setColor(Color.BLACK);
        mShadowPaint.setShadowLayer(10, 0, 0, Color.parseColor("#33000000"));

        // 初始化背景Drawable
        mBackgroundDrawable = getResources().getDrawable(R.drawable.background_shape);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        // 绘制阴影
        canvas.drawRect(0, 0, getWidth(), getHeight(), mShadowPaint);

        // 绘制背景
        mBackgroundDrawable.setBounds(0, 0, getWidth(), getHeight());
        mBackgroundDrawable.draw(canvas);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5