怎样用css使背景有立体感

html-css016

怎样用css使背景有立体感,第1张

教你如何制作具有立体感效果的我们详细的解释与说明CSS代码,看它是如何控制这个UL LI打造CSS横向菜单的:* {font-size:12px text-align:center}#nav {width:520px border-bottom:1px solid #06f margin:20px auto 0 auto}#nav li {display: inline list-style-type: none}#nav li a:link,#nav li a:visited {float:left margin-right:5px padding:5px 10px 5px 8px text-decoration: none color:#000 background:#ffe67d border-left: 5px solid #fc0}#nav li a:hover {color:#060 border-left: 5px solid #f60}首先我们进行了整体布局声明,声明了文字大小及居中的对齐方式。需要说明的是,在ff中,我们设置margin:0 auto。即可实现容器的居中了,但在IE中,这还不够,还需要在父容器中声明text-align:center。这一点我们要记得,不然容易出错。声明UL无序列表的宽度为520ox,下边框一象素的实现,颜色为#06f。我们设置了nav这个UL,距离顶部为20px、距离底部为零,左右的距离为auto。这就实现了nav在水平方向内是居中的,垂直方面上距离浏览器窗口20px。声明LI列表项为内联(行内)显示,列表预设标记为无。我们重点需要理解#nav li a:link,#nav li a:visited的定义,设置链接的样式。向左浮动,并且右边距为5px。这是设置链接元素从左向右排行,并且元素之间的右部间隔5px。设置填充,顶5px、右10px、下5px、左8px。这一设置可以使我们的链接文字处于合适的位置。取消链接文字的下划线,并设置链接文字的颜色为#000。链接元素的背景色为#ffe67d。左边框五象素的实线,颜色为#fc0。这一句话形成了我们的小竖条。我们通过下面#nav li a:hover形成鼠标激活的样式。链接文字的颜色变为#060。左边框五象素的实线,颜色为#f60。这样我们会动的小竖条菜单就制作完成了。看最终的代码:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" /><title>免费模板</title><style type="text/css">* {font-size:12px text-align:center}#nav {width:520px border-bottom:1px solid #06f margin:20px auto 0 auto}#nav li {display: inline list-style-type: none}#nav li a:link,#nav li a:visited {float:left margin-right:5px padding:5px 10px 5px 8px text-decoration: none color:#000 background:#ffe67d border-left: 5px solid #fc0}#nav li a:hover {color:#060 border-left: 5px solid #f60}</style></head><body><ul id="nav"> <li><a href="#">图象设计</a></li> <li><a href="#">网站运营</a></li> <li><a href="#">网络编程</a></li> <li><a href="#">创业指南</a></li> <li><a href="#">网站欣赏</a></li></ul></body></html>

代码:透明背景(带磨砂玻璃效果)  注:在粘贴到空白模板前一定先打个空格。

<STYLE type=text/css>

.bodytop{background:#transparent}

.banner{ background:#transparent}

.menu{ background:#transparent}

.bodyBg {background:#transparentfilter:progid:DXImageTransform.Microsoft.gradient(GradientType ='1',enabled='true',startColorstr=#AAFFFFFF, endColorstr=#AAFFFFFF)}

.zone{ background:#transparent}

.bodyBottom{background:#transparent}

.feeds .up{background:#transparent}

.feeds .down{background:#transparent }

.feeds .function{background:#transparent}

.feeds .page{background:#transparent}

.aList .sysHand .up{background:#transparent}

.aList .sysHand .down{background:#transparent}

.gbook .sysHand .up{background:#transparent}

.gbook .sysHand .down{background:#transparent}

.gbook .title{display:none}

.logo{display:none}

.gbook .page{background:#transparent }

.gbook .login{background:#transparent}

.box_1{background:#transparent}

.box_2{background:#transparent}

.calendar{background:#transparent}

.calendar .mid{background:#transparent}

.calendar .top{background:#transparent}

.calendar .title{background:#transparent}

.calendar .bold td{background:#transparent}

.calendar .bottom{background:#transparent}

.callboard .mid{background:#transparent}

.callboard .mid img{background:#transparent}

.callboard .front{background:#transparent}

.callboard .back{background:#transparent}

.callboard table{background:#transparent}

.callboard .up{background:#transparent}

.callboard .down{background:#transparent }

.sysBr{background:#transparent}

.sysBr210{background:#transparent}

.label{background:#transparent}

.label .mid{background:#transparent}

.label .top{background:#transparent}

.label .bottom{background:#transparent}

.photo{background:#transparent}

.photo .mid{background:#transparent}

.photo .image{background:#transparent}

.photo .top{background:#transparent}

.photo .bottom{background:#transparent}

.links{background:#transparent}

.links .up{background:#transparent}

.links .down{background:#transparent }

.links .mid{background:#transparent}

body{background:url("

http://s11.sinaimg.cn/orignal/439175a380fda7635072a

") repeat fixed!important}

.add{background:#transparent}

.add .ico{background:#transparent}

</STYLE>

假如页面有一个背景和一个透明的盒子,我们先将盒子范围内的背景截取下来,在透明盒子之后设置一个伪元素用绝对定位格式化长宽让其跟透明盒子一样大小,在将伪元素背景设置为刚刚截取的图片设置模糊、设置z-index让伪元素在透明盒子之后,在给透明盒子设置一点阴影就好了。

核心代码如下