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>
相关推荐
be or not to be1 天前
深入理解 CSS 浮动布局(float)
前端·css
南山安1 天前
Tailwind CSS:顺风CSS
javascript·css·react.js
王小菲1 天前
《网页布局速通:8 大主流方案 + 实战案例》-pink老师现代网页布局总结
css·面试·html
程序员刘禹锡1 天前
浮动以及导航条和简单布局!!!(12.29日)
css·html·css3
GDAL1 天前
从零开始上手 Tailwind CSS 教程
前端·css·tailwind
vim怎么退出1 天前
一次线上样式问题复盘:当你钻进 CSS 牛角尖时,问题可能根本不在 CSS
前端·css
yyf198905251 天前
CSS相关中文书籍
css
triumph_passion2 天前
Tailwind CSS v4 深度指南:目录架构与主题系统
前端·css
JAVA+C语言2 天前
CSS 继承:核心概念 + 实用解析
前端·css
OpenTiny社区2 天前
【博文精读】Chrome CSS 2025年回顾
前端·css