CSS3圆角与透明度设置
基本概念
0、圆角
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>圆角的设置</title>
<style type="text/css">
.box{
width: 300px;
height: 300px;
border: 3px solid black;
background-color: #f0ad4e;
margin: 50px auto 0;
border-top-left-radius: 60px 60px;
border-top-right-radius: 100px;
}
.box1{
width: 300px;
height: 300px;
border: 3px solid black;
background-color: #f0ad4e;
margin: 50px auto 0;
/*border-radius: 150px; !*方式一*!*/
border-top-right-radius: 150px;
border-bottom-left-radius: 150px;
}
.box2{
width: 300px;
height: 300px;
border: 3px solid black;
background-color: #f0ad4e;
margin: 50px auto 0;
/*border-radius: 150px; !*方式一*!*/
border-radius: 50%; /*方式二:以百分比的形式*/
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
显示效果如下所示:
1、盒子透明度设置
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>盒子透明度设置</title>
<style type="text/css">
.box{
opacity: 0.1;
/*兼容IE*/
filter: alpha(opacity=10);
background-color: #f0ad4e;
width: 200px;
height: 200px;
margin:50px auto 0;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
效果显示如下:
2、rgba透明度设置
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>48透明度的设置——rgba</title>
<style type="text/css">
body{
background: url("./images/banner01.jpg");
}
.box1{
width: 300px;
height: 100px;
background-color: black;
color: #ffffff;
font-size: 20px;
text-align: center;
line-height: 100px;
/*透明度设置*/
opacity: 0.5;
filter: alpha(opacity=0.3); /*兼容IE*/
}
.box2{
width: 300px;
height: 100px;
color: #ffffff;
font-size: 20px;
text-align: center;
line-height: 100px;
margin-top: 45px;
/*使用rgba*/
/*background-color: black;*/
background-color: rgba(0,0,0,0.3);
}
</style>
</head>
<body>
<div class="box1">这是一个盒子模型</div>
<div class="box2">嗯嗯</div>
</body>
</html>
显示效果如下所示: