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>
相关推荐
前端架构师-老李1 天前
HTML与CSS基础第五课—HTML的空格、换行、横线相关知识
前端·css·html
echome8881 天前
CSS 布局:Flex 和 Grid 怎么选,附常见坑
前端·css·html
东鹏特饮1 天前
本机状态监控页面html
运维·css·html·css3
蓝莓味的口香糖2 天前
【VUE】【CSS】Vue移动端适配主流方案总结
前端·css·vue.js
是立不是利2 天前
CSS 的 Flex 布局——为什么元素没有按我想的排列
前端·css
java1234_小锋3 天前
【技术专题】CSS3 网页技术 - CSS3 盒模型
前端·css·css3
前端架构师-老李3 天前
HTML与CSS基础第四课—strong、em、b、i 各表示什么
前端·css·html
程序0073 天前
天地图实现收货地址定位
前端·javascript·css
汤米粥3 天前
目前流行的前端 CSS 框架
前端·css·bootstrap·ant design·‌tailwind css·bulma
是立不是利3 天前
CSS 的层叠与优先级——为什么我的样式不生效
前端·css