Home  >  Article  >  Web Front-end  >  How to add shadow effect to div with css

How to add shadow effect to div with css

王林
王林forward
2020-09-02 16:42:074529browse

How to add shadow effect to div with css

This article shares with you how to add shadows to divs with css. I hope it can help you.

(Related recommendations: CSS tutorial)

Code implementation:

<style type="text/css">
.mydiv{
   width:250px; 
   height:auto;
   border:#909090 1px solid;
   background:#fff;
   color:#333;
   filter:progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4);
   -moz-box-shadow: 2px 2px 10px #909090;
   -webkit-box-shadow: 2px 2px 10px #909090;
   box-shadow:2px 2px 10px #909090;
}
</style>
 
for IE:
direction 阴影角度 0°为从下往上 顺时针方向
strength  阴影段长度
 
-moz-box-shadow: 2px 2px 10px #909090;
-webkit-box-shadow: 2px 2px 10px #909090;
box-shadow:2px 2px 10px #909090;
 
第一个参数是x轴阴影段长度
第二个参数是y轴阴影段长度
第三个参数是往四周阴影段长度
第四个参数是阴影段颜色
 
div代码:
<div class="mydiv">
    123123213123
</div>

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

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete