圆角矩形介绍

  • CSS中通过border-radius属性可以实现元素的圆角矩形。
  • border-radius属性值一共有4个,左上、右上、右下、左下。
  • border-radius属性值规则如下:第一个值为左上、第二个值为右上、第三个值为右下、第四个值为左下。
  • 假如border-radius属性值都是一致的我可以设置一个属性值即可。

圆角矩形实践

  • 圆角矩形基本使用方式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 100px;
height: 100px;
border: 2px solid rebeccapurple;
border-radius: 10px 20px 30px 40px;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

  • 如果我们的border-radius属性值一致实践。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 100px;
height: 100px;
border: 2px solid rebeccapurple;
border-radius: 20px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

  • 如果使用border-radius属性值将元素设置为圆形呢。
  • 第一步:要设置的元素宽高度必须一致。
  • 第二步:使用border-radius属性值必须是要设置的元素宽高度的一半。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 100px;
height: 100px;
border: 2px solid rebeccapurple;
border-radius: 50px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

  • 设置椭圆形实践
  • 实现椭圆形border-radius属性值必须是元素的高度一半即可。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 100px;
height: 50px;
border: 2px solid rebeccapurple;
border-radius: 25px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

设置半圆形

  • 设置右半圆形border-radius属性值左上、和左下为元素的宽度一致即可。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 50px;
height: 100px;
border: 2px solid rebeccapurple;
border-radius: 50px 0px 0px 50px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

  • 设置左半圆形border-radius属性值右上、和右下为元素的宽度一致即可。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 50px;
height: 100px;
border: 2px solid rebeccapurple;
border-radius: 0px 50px 50px 0px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

  • 设置上半圆形border-radius属性值左上、和右上为元素的高度一致即可。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 100px;
height: 50px;
border: 2px solid rebeccapurple;
border-radius: 50px 50px 0px 0px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

  • 设置下半圆形border-radius属性值左下、和右下为元素的高度一致即可。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>圆角矩形</title>
<style>
div{
width: 100px;
height: 50px;
border: 2px solid rebeccapurple;
border-radius: 0px 0px 50px 50px ;
}
</style>
</head>
<body>
<div></div>
</body>
</html>

最新文章

  1. XIB 上的控件不显示怎么办
  2. 【转】sql server 获取每一个类别中值最大的一条数据
  3. C#制作验证码
  4. ACM Haffman编码
  5. Linux下screen命令
  6. 快速、直接的XSS漏洞检测爬虫 – XSScrapy
  7. 【转】经典SQL语句大全
  8. jQuery扩展与noConflict的用法-小示例
  9. 创建 userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings 的配置节处理程序时出错: 未能加载文件或程序集“System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或它的某一个依赖项。系统没找到指定的文件
  10. MyEclipse 2015利用Cygwin+CDT搭建C/C++开发环境
  11. Konva入门教程
  12. 解决No converter found for return value of type: class java.util.ArrayList
  13. kali网络配置
  14. SpringBoot之AOP
  15. 20165313 《网络对抗技术》 Kali安装
  16. 一道题引出对LinkedList源码的研究
  17. 查询表DML和DDL操作的最后时间
  18. android studio git 将项目分享到github,推送到其他平台 码云 等。
  19. The type android.support.v4.view.ScrollingView cannot be resolved. It is indirectly referenced from
  20. dedecms 后台修改系统设置,但是config.cache.inc.php文件不能写入

热门文章

  1. 【js】vue 2.5.1 源码学习 (三) Vue.extend 和 data的合并策略
  2. P1027 三角形的周长
  3. activiti工作流引擎学习(二)
  4. Docker应用容器引擎
  5. hadoop常用端口及定义方法
  6. Typescript 最佳实践
  7. Vue+Element实现网页版个人简历系统
  8. scrapy分布式Spider源码分析及实现过程
  9. poj-1511
  10. DEVOPS技术实践_17:Jenkins使用扩展邮件功能发送邮件