css div 边框阴影利用背景图或内外层div实现层次感

建站知识 2021-07-03 08:43www.168986.cn长沙网站建设
两种实现方法一种是利用内外层的div边框来实例层次感觉的css边框阴影效果,另一种是利用了背景图片再加内外div来实现的这种效果更漂亮。
简单一点的纯css

复制代码
代码如下:

<head>
<metahttp-equiv="content-type"content="text/html;charset=gb2312"/>
<title>cssdiv边框阴影</title>
<styletype="text/css">
body{padding:200px;}
div{border-width:1px;border-style:solid;padding:1px;}
.a{background-color:#f3f3f3;border-color:#fbfbfb;}
.b{background-color:#d8d8d8;border-color:#e8e8e8;}
.c{background-color:#fff;border-color:#bbb;height:100px;color#ff0000;}
</style>
</head>
<body>
<divclass="a">
<divclass="b">
<divclass="c">边框为阴影效果</div>
</div>
</div>
</body>
</html>

复杂一点的利用图片背景

复制代码
代码如下:

<!doctypehtmlpublic"-//w3c//dtdxhtml1.0transitional//en""http://.027eat./tr/xhtml1/dtd/xhtml1-transitional.dtd">
<htmlxmlns="http://.027eat./1999/xhtml">
<head>
<title>css边框阴影</title>
<style>
.drops教程hadow2{
float:left;
clear:left;
background:url(http://.6a8a./uploadfile/2011/0621/20110621015322996.png)no-repeatbottomright!important;
background:url(http://.6a8a./uploadfile/2011/0621/20110621015329456.gif)no-repeatbottomright;
margin:10px010px10px!important;
margin:10px010px5px;
width:500px;
padding:0px;
}
.innerbox{
position:relative;
bottom:6px;
right:6px;
border:1pxsolid#999999;
padding:4px;
margin:0px0px0px0px;
}
.innerbox{
margin:0px0px-3px0px;
margin:0px0px0px0px;
}
.innerboxp{
font-size:14px;
margin:3px;
}
</style>
</head>
<body>
<divclass="dropshadow2"><divclass="innerbox"><h4>css阴影</h4><p>这段边框阴影效果怎么样呢?</p></div></div>
</body>
</html>

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by