百度有啊的 CSS 圆角写法,原理和《一张图片实现圆角》差不多,也是用背景定位实现的。
看代码吧: XHTML 代码:
CSS 代码:
.box1 {
background:url(images/bg1.gif) repeat-x #1d6cb7;
margin-top:1em;
position:relative;
zoom:1;
width:778px;
}
.box1 .tl, .box1 .tr, .box1 .bl, .box1 .br {
width:5px;
height:5px;
position:absolute;
background:url(images/bg3.gif) no-repeat;
overflow:hidden;
}
.box1 .cc {
height:40px;
padding:5px;
}
.box1 .tl {
left:0;
top:0;
}
.box1 .tr {
right:0;
top:0;
background-position:0 -5px;
}
.box1 .bl {
left:0;
bottom:0;
background-position:0 -10px;
}
.box1 .br {
right:0;
bottom:0;
background-position:0 -15px;
}
看看上面代码所用到的图片能更好的理解(下面):
第一部分是左上角的,第二部分是右上角的,第三部分是左下角的,第四部分是右下角的。
提示:您可以先修改部分代码再运行
复制代码
代码如下:圆角一
CSS 代码:
复制代码
代码如下:.box1 {
background:url(images/bg1.gif) repeat-x #1d6cb7;
margin-top:1em;
position:relative;
zoom:1;
width:778px;
}
.box1 .tl, .box1 .tr, .box1 .bl, .box1 .br {
width:5px;
height:5px;
position:absolute;
background:url(images/bg3.gif) no-repeat;
overflow:hidden;
}
.box1 .cc {
height:40px;
padding:5px;
}
.box1 .tl {
left:0;
top:0;
}
.box1 .tr {
right:0;
top:0;
background-position:0 -5px;
}
.box1 .bl {
left:0;
bottom:0;
background-position:0 -10px;
}
.box1 .br {
right:0;
bottom:0;
background-position:0 -15px;
}
看看上面代码所用到的图片能更好的理解(下面):
第一部分是左上角的,第二部分是右上角的,第三部分是左下角的,第四部分是右下角的。
提示:您可以先修改部分代码再运行
以上就是百度有啊 CSS圆角实现代码的详细内容,更多请关注0133技术站其它相关文章!