• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

    HTML+css盒子模型案例(圆,半圆等)“border-radius” 简单易上手

    发布者: 怀142 | 发布时间: 2025-8-16 21:38| 查看数: 44| 评论数: 0|帖子模式

    很多小伙伴在前端学习的时候,发现盒子模型默认为正方形。如何把盒子变成想要的模型呢? 首先我们来看一下默认的情况----
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4.     <meta charset="UTF-8">
    5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6.     <meta name="viewport" content="width=, initial-scale=1.0">
    7.     <style>
    8.         .box{
    9.             width: 100px;
    10.             height: 100px;
    11.             background-color: rgb(116, 51, 51);
    12.             box-shadow:0 10px 10px red;
    13.             text-align: center;
    14.             position:absolute;
    15.             margin:0 auto;   
    16.             left:0;
    17.             right:0;
    18.             bottom:0;
    19.             top:0;

    20.         }
    21.     </style>
    22.     <title>Document</title>
    23. </head>
    24. <body>
    25.     <div class="box">

    26.     </div>
    27. </body>
    28. </html>
    复制代码

    默认情况下为正方形,也许小伙伴觉得不太好看。 我们换成圆形的试试!
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4.     <meta charset="UTF-8">
    5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7.     <style>
    8.         .box{
    9.             width: 100px;
    10.             height: 100px;
    11.             border-radius: 50%;
    12.             background-color: rgb(28, 99, 60);
    13.             border: 5px solid rgb(55, 0, 255);
    14.             position: absolute;
    15.             margin: 0 auto;
    16.             left: 0;
    17.             right: 0;
    18.             bottom: 0;
    19.             top: 0;
    20.         }
    21.     </style>
    22.     <title>Round</title>
    23. </head>
    24. <body>
    25.     <div class="box">

    26.     </div>
    27. </body>
    28. </html>
    复制代码

    看一下我们变成了圆形! 来看看半圆形的吧!
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4.     <meta charset="UTF-8">
    5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7.     <style>
    8.         .box{
    9.             width: 100px;
    10.             height: 50px;
    11.             background-color: rgb(175, 42, 216);
    12.             border: 3px solid rgb(26, 236, 26);
    13.             border-top-right-radius: 50px;
    14.             border-top-left-radius: 50px;
    15.             position:absolute;
    16.             margin: 0 auto;
    17.             left: 0;
    18.             right: 0;
    19.             bottom: 0;
    20.             top: 0;
    21.         }
    22.     </style>
    23.     <title>semicircle</title>
    24. </head>
    25. <body>
    26.     <div class="box">

    27.     </div>
    28. </body>
    29. </html>
    复制代码

    来试试其他形状!
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4.     <meta charset="UTF-8">
    5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7.     <style>
    8.         .box{
    9.             width: 100px;
    10.             height: 100px;
    11.             background-color: rgb(82, 84, 223);
    12.             border-radius: 20px 15px 20px 10px;
    13.             position: absolute;
    14.             margin: 0 auto;
    15.             left: 0;
    16.             bottom: 0;
    17.             right: 0;
    18.             top: 0;
    19.         }
    20.     </style>
    21.     <title>demo</title>
    22. </head>
    23. <body>
    24.     <div class="box">

    25.     </div>
    26. </body>
    27. </html>
    复制代码

    知识点分析:
    1. border-radius:给元素设置圆角边框
    2. 可以实现圆,半圆,椭圆,四分之一圆等各种圆角图形。
    3. 可以设置四个值,分别为左上,右上,右下,左下
    4. 给个口诀,“从左上开始顺时针移动”。。。
    复制代码
    希望这篇文章能让你学会border-radius属性!
    到此这篇关于HTML+css盒子模型案例(圆,半圆等)“border-radius” 简单上手的文章就介绍到这了,更多相关html css盒子模型内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

    来源:互联网
    免责声明:如果侵犯了您的权益,请联系站长(1277306191@qq.com),我们会及时删除侵权内容,谢谢合作!

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×

    最新评论

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表