纯CSS+DIV实现圆角的三种方法
来源:互联网 发布:济南链企网络 编辑:程序博客网 时间:2024/05/08 05:41
方法一:使用"•"来当圆角:
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
function doResize()
{
document.getElementById("box-contents").style.height=(document.documentElement.clientHeight-60)+"px";
}
window.onresize = doResize;
</script>
<style type="text/css">
body
{
background-color: black;
margin: 0px;
padding: 0px;
color: White;
font: 16px arial;
}
#content
{
margin: auto;
width: 780px;
height: 100%;
padding: 0 0;
}
div.rounded-box
{
position: relative;
background-color: red;
margin: 3px;
width: 780px;
padding: 0 0;
}
/*********************
GLOBAL ATTRIBUTES
*********************/div.top-left-corner, div.bottom-left-corner, div.top-right-corner, div.bottom-right-corner
{
position: absolute;
width: 20px;
height: 20px;
background-color: black;
overflow: hidden;
}
div.top-left-inside, div.bottom-left-inside, div.top-right-inside, div.bottom-right-inside
{
position: relative;
font-size: 150px;
font-family: arial;
color: red;
line-height: 40px;
}
/*********************
SPECIFIC ATTRIBUTES
*********************/div.top-left-corner
{
top: 0px;
left: 0px;
}
div.bottom-left-corner
{
bottom: 0px;
left: 0px;
}
div.top-right-corner
{
top: 0px;
right: 0px;
}
div.bottom-right-corner
{
bottom: 0px;
right: 0px;
}
div.top-left-inside
{
left: -8px;
}
div.bottom-left-inside
{
left: -8px;
top: -17px;
}
div.top-right-inside
{
left: -25px;
}
div.bottom-right-inside
{
left: -25px;
top: -17px;
}
div.box-contents
{
position: relative;
padding: 8px;
color: white;
}
</style>
</head>
<body onload="doResize();">
<div id="content">
<span>Header</span>
<div class="rounded-box">
<div class="top-left-corner">
<div class="top-left-inside">
•</div>
</div>
<div class="bottom-left-corner">
<div class="bottom-left-inside">
•</div>
</div>
<div class="top-right-corner">
<div class="top-right-inside">
•</div>
</div>
<div class="bottom-right-corner">
<div class="bottom-right-inside">
•</div>
</div>
<div class="box-contents" id="box-contents">
Contents go here, but it must be at least two lines to look any good.
<br>
Contents go here, but it must be at least two lines to look any good.
<br>
Contents go here, but it must be at least two lines to look any good.
<br>
</div>
<!-- end div.box-contents -->
</div>
<!-- end div.rounded-box -->
<span>Footer</span>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
function doResize()
{
document.getElementById("box-contents").style.height=(document.documentElement.clientHeight-60)+"px";
}
window.onresize = doResize;
</script>
<style type="text/css">
body
{
background-color: black;
margin: 0px;
padding: 0px;
color: White;
font: 16px arial;
}
#content
{
margin: auto;
width: 780px;
height: 100%;
padding: 0 0;
}
div.rounded-box
{
position: relative;
background-color: red;
margin: 3px;
width: 780px;
padding: 0 0;
}
/*********************
GLOBAL ATTRIBUTES
*********************/div.top-left-corner, div.bottom-left-corner, div.top-right-corner, div.bottom-right-corner
{
position: absolute;
width: 20px;
height: 20px;
background-color: black;
overflow: hidden;
}
div.top-left-inside, div.bottom-left-inside, div.top-right-inside, div.bottom-right-inside
{
position: relative;
font-size: 150px;
font-family: arial;
color: red;
line-height: 40px;
}
/*********************
SPECIFIC ATTRIBUTES
*********************/div.top-left-corner
{
top: 0px;
left: 0px;
}
div.bottom-left-corner
{
bottom: 0px;
left: 0px;
}
div.top-right-corner
{
top: 0px;
right: 0px;
}
div.bottom-right-corner
{
bottom: 0px;
right: 0px;
}
div.top-left-inside
{
left: -8px;
}
div.bottom-left-inside
{
left: -8px;
top: -17px;
}
div.top-right-inside
{
left: -25px;
}
div.bottom-right-inside
{
left: -25px;
top: -17px;
}
div.box-contents
{
position: relative;
padding: 8px;
color: white;
}
</style>
</head>
<body onload="doResize();">
<div id="content">
<span>Header</span>
<div class="rounded-box">
<div class="top-left-corner">
<div class="top-left-inside">
•</div>
</div>
<div class="bottom-left-corner">
<div class="bottom-left-inside">
•</div>
</div>
<div class="top-right-corner">
<div class="top-right-inside">
•</div>
</div>
<div class="bottom-right-corner">
<div class="bottom-right-inside">
•</div>
</div>
<div class="box-contents" id="box-contents">
Contents go here, but it must be at least two lines to look any good.
<br>
Contents go here, but it must be at least two lines to look any good.
<br>
Contents go here, but it must be at least two lines to look any good.
<br>
</div>
<!-- end div.box-contents -->
</div>
<!-- end div.rounded-box -->
<span>Footer</span>
</div>
</body>
</html>
方法二:
来自:http://www.cnblogs.com/scgw/articles/927682.html
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
u.corner u
{
height: 1px;
font-size: 1px;
display: block;
overflow: hidden; /*author: meizz*/
text-decoration: none;
background-color: green;
}
u.corner u.h1
{
margin: 0 5px;
}
u.corner u.h2
{
margin: 0 3px;
}
u.corner u.h3
{
margin: 0 2px;
}
u.corner u.h4
{
margin: 0 1px;
height: 2px;
}
</style>
<head>
<body>
<div>
<u class="corner"><u class="h1"></u><u class="h2"></u><u class="h3"></u><u class="h4">
</u></u>
<div style="background-color: green; height: 200">
content</div>
<u class="corner"><u class="h4"></u><u class="h3"></u><u class="h2"></u><u class="h1">
</u></u>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
u.corner u
{
height: 1px;
font-size: 1px;
display: block;
overflow: hidden; /*author: meizz*/
text-decoration: none;
background-color: green;
}
u.corner u.h1
{
margin: 0 5px;
}
u.corner u.h2
{
margin: 0 3px;
}
u.corner u.h3
{
margin: 0 2px;
}
u.corner u.h4
{
margin: 0 1px;
height: 2px;
}
</style>
<head>
<body>
<div>
<u class="corner"><u class="h1"></u><u class="h2"></u><u class="h3"></u><u class="h4">
</u></u>
<div style="background-color: green; height: 200">
content</div>
<u class="corner"><u class="h4"></u><u class="h3"></u><u class="h2"></u><u class="h1">
</u></u>
</div>
</body>
</html>
方法三:
来自:http://www.cnblogs.com/pointdeng/articles/1171323.html
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>无标题页</title>
<style>
.up1
{
overflow: hidden;
height: 1px;
margin-left: 4px;
margin-right: 4px;
background-color: Aqua;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.up2
{
overflow: hidden;
height: 1px;
margin-left: 3px;
margin-right: 3px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.up3
{
overflow: hidden;
height: 1px;
margin-left: 2px;
margin-right: 2px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.content
{
margin-left: 1px;
margin-right: 1px;
height: 100px; /*这里控件高度*/ /*background-color: Aqua;*/
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.down1
{
overflow: hidden;
height: 1px;
margin-left: 2px;
margin-right: 2px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.down2
{
overflow: hidden;
height: 1px;
margin-left: 3px;
margin-right: 3px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.down3
{
overflow: hidden;
height: 1px;
margin-left: 4px;
margin-right: 4px;
background-color: Aqua;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.cell
{
width: 50px; /*这里控制宽度*/
}
</style>
</head>
<body>
<div class="cell">
<div class="up1">
</div>
<div class="up2">
</div>
<div class="up3">
</div>
<div class="content">
这里放内容
</div>
<div class="down1">
</div>
<div class="down2">
</div>
<div class="down3">
</div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>无标题页</title>
<style>
.up1
{
overflow: hidden;
height: 1px;
margin-left: 4px;
margin-right: 4px;
background-color: Aqua;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.up2
{
overflow: hidden;
height: 1px;
margin-left: 3px;
margin-right: 3px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.up3
{
overflow: hidden;
height: 1px;
margin-left: 2px;
margin-right: 2px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.content
{
margin-left: 1px;
margin-right: 1px;
height: 100px; /*这里控件高度*/ /*background-color: Aqua;*/
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.down1
{
overflow: hidden;
height: 1px;
margin-left: 2px;
margin-right: 2px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.down2
{
overflow: hidden;
height: 1px;
margin-left: 3px;
margin-right: 3px;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.down3
{
overflow: hidden;
height: 1px;
margin-left: 4px;
margin-right: 4px;
background-color: Aqua;
border-left: solid 1px Aqua;
border-right: solid 1px Aqua;
}
.cell
{
width: 50px; /*这里控制宽度*/
}
</style>
</head>
<body>
<div class="cell">
<div class="up1">
</div>
<div class="up2">
</div>
<div class="up3">
</div>
<div class="content">
这里放内容
</div>
<div class="down1">
</div>
<div class="down2">
</div>
<div class="down3">
</div>
</div>
</body>
</html>
原文地址:http://www.cnblogs.com/blodfox777/archive/2008/09/02/1282141.html
- 纯CSS+DIV实现圆角的三种方法
- 纯div+css实现手风琴效果下拉框的两种方法
- 纯CSS实现三列DIV等高布局
- 纯CSS实现三列DIV等高布局
- 用纯div+css实现最简单的圆角处理
- 纯CSS实现圆角、可拖动的一个DIV弹出层
- 一款很棒的纯CSS制作的圆角DIV
- 纯DIV+CSS实现进度条
- 纯DIV+CSS制作圆角矩形
- 纯css实现Tab切换的两种方法
- 纯CSS实现垂直居中的几种方法
- 纯CSS实现垂直居中的几种方法
- 纯CSS实现垂直居中的几种方法
- 纯CSS实现圆角
- Div+css_页面使用css的三种方法
- 纯js+css实现 页面弹出div
- css 实现div垂直居中的几种方法
- CSS实现半透明div层的方法
- 关于我所碰到的问题中的[枚举]
- 在SDK中取得设备内容句柄的五种方法
- 职业发展?
- 深入了解:液晶显示器的工作原理 3
- 2009工程计算国际会议(ICEC2009)
- 纯CSS+DIV实现圆角的三种方法
- PHP-Javascript“返回上一页”无缓存问题
- 一个 SPI 转串口驱动的优化
- 简单试试
- c++中类变量的初始化
- php配置文件php.ini的中文注释版
- 游戏开发问题
- Java你不得不知道的,却总是感到迷惑的东西
- Tomcat发布项目方法