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>
相关推荐
用户0595401744612 小时前
「记仇」记忆存储测试踩坑实录:用 Pytest+Docker 把 BUG 扼杀在凌晨 3 点前
前端·css
用户059540174461 天前
Redis 记忆存储踩坑实录:一个并发写入 Bug 让我排查了 4 小时
前端·css
10WTW011 天前
Sprite-Motion-Lab:雪碧图动画编辑器
前端·css·雪碧图·spritemotionlab·10wtw01
醉城夜风~2 天前
CSS元素显示模式(display)
前端·css
开普勒chr2 天前
css样式diaplay:"contents"的妙用
css
软件技术NINI2 天前
盗墓笔记html+css+js 2页
css·笔记·html
用户059540174463 天前
大模型对话记忆持久化踩坑实录:用 Playwright 自动化测了 300 次,终于揪出会话丢失的真凶
前端·css
林焱_RPAAI3 天前
影刀RPA操作数据库进阶:事务处理与批量写入优化
css
牧艺3 天前
cos-design PhotoAlbum:用 CSS 3D 做一个「能翻页」的实体相册
前端·css·交互设计
muddjsv4 天前
CSS 盒模型进阶约束:极值尺寸、固有尺寸与外边距折叠
前端·css