CSS绘制圆弧

css绘制如图的圆弧:

这种矩形+弧形的效果中,弧形的效果一般是由一条曲线拉伸出来的,这条曲线往往是属于一个椭圆的,所以可以绘制一个椭圆,截取部分可视区域实现效果。

html 复制代码
  <style>
.wrapper{
  width: 400px;
  height: 600px;
  border: 2px solid saddlebrown;
  position: relative;
  overflow: hidden;
}

.arc-continer{
  width: 100%;
  /* 高度设置为 圆弧形状整体高度 */
  height: 259px;
  background-color: transparent;
  position: relative;
}

/* 绘制椭圆 :长半轴为容器宽度*2左右,短半轴为容器宽度*1 左右 -- 可以根据需要进行微调*/
.arc-continer::after{
  content: '';
  width: 200%;
  height:400px;
  background-color: aqua;
  position: absolute;
  /* 绘制为椭圆 */
  border-radius: 100% /100%;
  /* top 为  椭圆高度 - arc-continer高度*/
  top: -141px;
  left: 50%;
  transform: translateX(-50%);
}
  </style>
</head>

<body>
  <div class="wrapper" id="wrap">
    <div class="arc-continer" id="continer">
    </div>
  </div>
</body>
相关推荐
岱宗夫up17 小时前
【前端基础】HTML + CSS + JavaScript 快速入门
前端·css·html
CappuccinoRose1 天前
CSS 语法学习文档(十九)
前端·css·属性·flex·grid·学习资源·格式化上下文
肖。35487870942 天前
html中onclick误区,后续变量会更改怎么办?
android·java·javascript·css·html
用户5757303346242 天前
🎨 CSS变量彻底指南:从入门到精通,99%的人不知道的动态样式魔法!
css
用户5757303346242 天前
🎯 CSS 定位详解:从入门到面试通关
css
凯里欧文4272 天前
🔥真正高级的前端,早就用这 10 个 CSS 特性干掉 80% 冗余代码
前端·css
Never_Satisfied2 天前
在HTML & CSS中,letter-spacing详解
前端·css·html
Never_Satisfied2 天前
在HTML & CSS中,Animation 属性使用详解
前端·css·html
明月_清风2 天前
告别视口依赖:Container Queries 开启响应式组件的“后媒体查询”时代
前端·css
明月_清风2 天前
从样式表到渲染引擎:2026 年前端必须掌握的 CSS 架构新特性
前端·css