将button变成圆形(有弧度)

border-radius可以将button变成圆形,也可以给div加有弧度边框

border-radius 规则:

一个值: 四个圆角值相同

两个值: 第一个值为左上角与右下角,第二个值为右上角与左下角

三个值: 第一个值为左上角, 第二个值为右上角和左下角,第三个值为右下角

四个值: 第一个值为左上角,第二个值为右上角,第三个值为右下角,第四个值为左下角。

样式:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
		
			.btn{
				width: 100px;
				height: 30px;
				background: green;
				border: none;
				color: white;
				margin: 6px 10px;
			}
			.btnStyle1{
				border-radius: 6px;
			}
			.btnStyle2{
				border-radius: 26px 6px;
			}
			.btnStyle3{
				border-radius: 6px 26px 60px;
			}
			.btnStyle4{
				border-radius: 6px 126px 236px 346px;
			}
			.bolder{
				border: solid 1px green;
				width: 500px;
				height: 40px;
				border-radius: 10px;
			}
		</style>
	</head>
	<body>
		<div class="bolder">
		<button class="btn btnStyle1">按钮1</button>
		<button class="btn btnStyle2">按钮2</button>
		<button class="btn btnStyle3">按钮3</button>
		<button class="btn btnStyle4">按钮4</button>
		</div>
	</body>
</html>

有时候border-radius会失效

解决办法:万能的!important;

在border-radius属性里面添加 !important,让浏览器首选执行这个语句

border-radius: 6px !important;

CSS中的!important一般都是用于对低版本的除了iE 6 ,用来做hack的,后面缀上了!important的css语句,让浏览器首选执行这个语句,因为css有继承的样式,加上!importanrt可以覆盖父级的样式。

 

个人网站欢迎来访

http://www.leixingke.com/

  • 12
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值