HTML学习-13css3圆角和透明色

目录

一、圆角

1.分别设置四个角

a.讲解

2.画一个圆

3.总结

4.其他资料

二、透明度设置

 1.设置opacity

 2.设置rbga


一、圆角

1.分别设置四个角

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			.box{
				width: 300px;
				height: 300px;
				border: 3px solid #000;
				background-color: gold;
				margin: 50px auto 0;
				/* 针对某一个角做圆角 */
				border-top-left-radius: 30px 60px;/* 表示一边为半径30画弧一边为60 */
				border-top-left-radius:60px;/* 表示这个角为60px画的弧 */
				border-top-right-radius:60px ;
				border-bottom-right-radius: 60px;
				border-bottom-left-radius: 60px;
				border-radius: 60px;/* 四个角一句话表示 */
				
			}

		</style>
		<title></title>
	</head>
	<body>
		<div class="box"></div>
	</body>
</html>

a.讲解

border-top-left-radius: 30px 60px;/* 表示一边为半径30画弧一边为60 */
                border-top-left-radius:60px;/* 表示这个角为60px画的弧 */
                border-top-right-radius:60px ;
                border-bottom-right-radius: 60px;
                border-bottom-left-radius: 60px;
                border-radius: 60px;/* 四个角一句话表示 */

2.画一个圆

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			.box1{
				width: 300px;
				height: 300px;
				border: 3px solid #000;
				background-color: gold;
				margin: 50px auto 0;
				/* 如果border-radius正好为宽高的50%则画一个正圆 */
				border-radius: 150px;/* 50%也一样的作用 */
			}
		</style>
		<title></title>
	</head>
	<body>
		<div class="box1"></div>
	</body>
</html>

width: 300px;
height: 300px;
/* 如果border-radius正好为宽高的50%则画一个正圆 */
border-radius: 150px;/* 50%也一样的作用 */

3.总结

对于border-radius相当于设置半径,而这个半径可以设置不同方向的比如:border-bottom-left-radius设置左下角。依此类推可以完成四个角的设置,如果四个角都相同则可以直接一句话带过border-radius:60px;而对于如果设置border-radius:50%;则画一个完整的圆。

4.其他资料

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			.box{
				width: 300px;
				height: 300px;
				border: 3px solid #000;
				background-color: gold;
				margin: 50px auto 0;
				/* 针对某一个角做圆角 */
				border-top-left-radius: 30px 60px;/* 表示一边为半径30画弧一边为60 */
				border-top-left-radius:60px;/* 表示这个角为60px画的弧 */
				border-top-right-radius:60px ;
				border-bottom-right-radius: 60px;
				border-bottom-left-radius: 60px;
				border-radius: 60px;/* 四个角一句话表示 */
				
			}
			.box1{
				width: 300px;
				height: 300px;
				border: 3px solid #000;
				background-color: gold;
				margin: 50px auto 0;
				/* 如果border-radius正好为宽高的50%则画一个正圆 */
				border-radius: 150px;/* 50%也一样的作用 */
			}
			.box2{
				width: 300px;
				height: 300px;
				border: 3px solid #000;
				background-color: gold;
				margin: 50px auto 0;
				border-top-right-radius: 50%;
				border-bottom-left-radius: 50%;/* 画芒果 */
			}
		</style>
		<title></title>
	</head>
	<body>
		<div class="box"></div>
		<div class="box1"></div>
		<div class="box2"></div>
	</body>
</html>

二、透明度设置

 1.设置opacity

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			body{
				background: url(./banner01.jpg);
			}
			.box{
				width: 300px;
				height: 100px;
				background-color: black;
				color: aliceblue;
				font-size: 30px;
				text-align: center;
				line-height: 100px;
				opacity: 0.3;/* 设置透明度 */
				/* 兼容IE */
				filter: alpha(opacity=30);/* 字和盒子整体变成0.3的透明度要与之前的相对应30 和 0.3*/
				
			}
		</style>
		<title></title>
	</head>
	<body>
		<div class="box">这是一个div</div>
	</body>
</html>

opacity: 0.3;/* 设置透明度 */
 /* 兼容IE */
filter: alpha(opacity=30);/* 字和盒子整体变成0.3的透明度要与之前的相对应30 和 0.3*/ 

虽然opacity进行设置透明度,但是为了兼容IE浏览器所以加filter: alpha(opacity=30);

 从图片中可知该方法把背景颜色和字体都进行了透明操作

 2.设置rbga

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			body{
				background: url(./banner01.jpg);
			}

			.box2{
				width: 300px;
				height: 100px;
				background-color: rgba(0,0,0,0.3);/* 仅背景透明度进行,文字颜色不动 */
				color: aliceblue;
				font-size: 30px;
				text-align: center;
				line-height: 100px;
				margin-top: 50px;
				
			}
		</style>
		<title></title>
	</head>
	<body>
		<div class="box2">这个是第二个div</div>
	</body>
</html>

 background-color: rgba(0,0,0,0.3);前三个值与rgb表示相同,后面的0.3表示透明色

该方法只对背景进行透明对字体没有影响

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

『Knight』

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值