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>
相关推荐
站在风口的猪11085 小时前
《前端面试题:CSS预处理器(Sass、Less等)》
前端·css·html·less·css3·sass·html5
Hygge-star6 小时前
【Flask】:轻量级Python Web框架详解
css·flask·html·学习方法·web app
牧码岛12 小时前
Web前端之隐藏元素方式的区别、Vue循环标签的时候在同一标签上隐藏元素的解决办法、hidden、display、visibility
前端·css·vue·html·web·web前端
棉花糖超人15 小时前
【从0-1的CSS】第1篇:CSS简介,选择器已经常用样式
前端·css
potender16 小时前
前端基础学习html+css+js
前端·css·学习·html·js
Hilaku16 小时前
你以为的 Tailwind 并不高效,看看这些使用误区
前端·css·前端框架
Hilaku16 小时前
为什么越来越多 Vue 项目用起了 UnoCSS?
前端·css·html
中微子17 小时前
☀️这些CSS里的选择器你知道多少❓
css
Larcher17 小时前
css真难,那就从基础开始吧
前端·css
Linsk17 小时前
深入解析 Sass 的 `~` 路径问题:为什么你的导入会失败?
css·scss·前端工程化