当前位置:网站首页>一篇文章带你了解CSS3圆角知识
一篇文章带你了解CSS3圆角知识
2020-11-06 20:42:00 【Python进阶者】
一、浏览器支持
表中的数字指定完全支持该属性的第一个浏览器版本。
数字后面的 -webkit- 或者 -moz- 使用时需要指定前缀。
属性 | Chrome | Firefox | Safari | Opera | IE |
---|---|---|---|---|---|
border-radius | 5.0 4.0 -webkit- | 9.0 | 4.0 3.0 -moz- | 5.0 3.1 -webkit- | 10.5 |
二、border-radius 属性
1. 创建具有背景图的圆角
CSS3中,可以使用border-radius
属性,为元素指定圆角显示。
代码如下:
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<title>项目</title>
<head>
<style>
#rcorners1 {
border-radius: 25px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners2 {
border-radius: 25px;
border: 2px solid #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners3 {
border-radius: 25px;
background: url(img/fy_indexBg.jpg);
background-position: left top;
background-repeat: repeat;
padding: 20px;
width: 200px;
height: 150px;
}
</style>
</head>
<body>
<p>The border-radius property allows you to add rounded corners to elements.</p>
<p>Rounded corners for an element with a specified background color:</p>
<!--1.具有指定背景色的圆角元素-->
<p id="rcorners1">Rounded corners!</p>
<p>Rounded corners for an element with a border:</p>
<!--2.带边框的圆角元素:-->
<p id="rcorners2">Rounded corners!</p>
<!--3.带背景图的圆角元素-->
<p>Rounded corners for an element with a background image:</p>
<p id="rcorners3">Rounded corners!</p>
</body>
</html>
提示:
border-radius
属性实际是border-top-left-radius
, border-top-right-radius
, border-bottom-right-radius
和 border-bottom-left-radius
属性的简写。
2. 为每个角指定弧度
如果只为border-radius
属性指定一个值,则此半径将应用于所有4个角。
另外可以根据自己开发的需求,分别指定每个角。以下是规则:
四个值: 第一个值适用于左上角,第二个值适用于右上方,第三值应用于右下角,第四值适用于左下角。
三个值: 第一个值适用于左上,二值适用于右上和左下,右下第三值适用于。
两个值: 第一个值适用于左上和右下角,和二值适用于右上和左下角。
一个值: 所有的四个角都是圆的。
实例1:
1.四个值 - border-radius: 15px 50px 30px 5px
#rcorners4 {
border-radius: 15px 50px 30px 5px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
2.三个值 - border-radius: 15px 50px 30px
#rcorners5 {
border-radius: 15px 50px 30px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
3.两个值 - border-radius: 15px 50px
#rcorners6 {
border-radius: 15px 50px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
完整代码 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>项目</title>
<style>
#rcorners4 {
border-radius: 15px 50px 30px 5px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners5 {
border-radius: 15px 50px 30px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners6 {
border-radius: 15px 50px;
background: #f00;
padding: 20px;
width: 200px;
height: 150px;
}
</style>
</head>
<body>
<p>四个值 - border-radius: 15px 50px 30px 5px:</p>
<p id="rcorners4"></p>
<p>三个值 - border-radius: 15px 50px 30px:</p>
<p id="rcorners5"></p>
<p>两个值 - border-radius: 15px 50px:</p>
<p id="rcorners6"></p>
</body>
</html>
实例2:
创建椭圆形的圆角
创建椭圆形的圆角
椭圆边框 :border-radius: 50px/15px
#rcorners7 {
border-radius: 50px/15px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
椭圆边框 : border-radius: 15px/50px
#rcorners8 {
border-radius: 15px/50px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
椭圆边框 : border-radius: 50%
#rcorners9 {
border-radius: 50%;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
完整代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>项目</title>
<style>
#rcorners7 {
border-radius: 50px/15px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners8 {
border-radius: 15px/50px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners9 {
border-radius: 50%;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
</style>
</head>
<body>
<p>椭圆边框 - border-radius: 50px/15px:</p>
<p id="rcorners7"></p>
<p>椭圆边框 - border-radius: 15px/50px:</p>
<p id="rcorners8"></p>
<p>椭圆边框 - border-radius: 50%:</p>
<p id="rcorners9"></p>-->
</body>
</html>
三、总结
1、本文主要讲解了CSS3圆角,通过一些属性的演示,丰富的案例,帮助大家理解CSS知识。希望大家可以耐心的去学习,同时希望碰到问题主动搜索,尝试一下,总会有解决方法。
2、代码很简单,希望能帮到你。
想学习更多Python网络爬虫与数据挖掘知识,可前往专业网站:http://pdcfighting.com/ 想学习更多Python网络爬虫与数据挖掘知识,可前往专业网站:http://pdcfighting.com/
版权声明
本文为[Python进阶者]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4521128/blog/4703060
边栏推荐
- Wiremock: a powerful tool for API testing
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
- Thoughts on interview of Ali CCO project team
- 助力金融科技创新发展,ATFX走在行业最前列
- hadoop 命令总结
- Filecoin的经济模型与未来价值是如何支撑FIL币价格破千的
- Basic principle and application of iptables
- 中小微企业选择共享办公室怎么样?
- GDB除錯基礎使用方法
- Just now, I popularized two unique skills of login to Xuemei
猜你喜欢
How to select the evaluation index of classification model
Filecoin的经济模型与未来价值是如何支撑FIL币价格破千的
合约交易系统开发|智能合约交易平台搭建
3分钟读懂Wi-Fi 6于Wi-Fi 5的优势
PLC模拟量输入和数字量输入是什么
Working principle of gradient descent algorithm in machine learning
在大规模 Kubernetes 集群上实现高 SLO 的方法
钻石标准--Diamond Standard
GUI 引擎评价指标
git rebase的時候捅婁子了,怎麼辦?線上等……
随机推荐
Didi elasticsearch cluster cross version upgrade and platform reconfiguration
DRF JWT authentication module and self customization
Troubleshooting and summary of JVM Metaspace memory overflow
如何将数据变成资产?吸引数据科学家
How to get started with new HTML5 (2)
Filecoin主网上线以来Filecoin矿机扇区密封到底是什么意思
Dapr實現分散式有狀態服務的細節
合约交易系统开发|智能合约交易平台搭建
比特币一度突破14000美元,即将面临美国大选考验
Jmeter——ForEach Controller&Loop Controller
怎么理解Python迭代器与生成器?
连肝三个通宵,JVM77道高频面试题详细分析,就这?
Synchronous configuration from git to consult with git 2consul
Deep understanding of common methods of JS array
ES6学习笔记(五):轻松了解ES6的内置扩展对象
中小微企业选择共享办公室怎么样?
数字城市响应相关国家政策大力发展数字孪生平台的建设
Polkadot series (2) -- detailed explanation of mixed consensus
【效能優化】納尼?記憶體又溢位了?!是時候總結一波了!!
Existence judgment in structured data