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>
相关推荐
掘金安东尼4 小时前
纯 CSS 实现弹性文字效果
前端·css
前端Hardy11 小时前
HTML&CSS&JS:打造丝滑的3D彩纸飘落特效
前端·javascript·css
前端Hardy11 小时前
HTML&CSS&JS:丝滑无卡顿的明暗主题切换
javascript·css·html
parade岁月1 天前
Tailwind CSS v4 — 当框架猜不透你的心思
前端·css
前端Hardy2 天前
HTML&CSS&JS:基于定位的实时天气卡片
javascript·css·html
程序员阿耶2 天前
5 个让 CSS 起飞的新特性,设计师看了直呼内行
css
前端Hardy2 天前
HTML&CSS:纯CSS实现随机转盘抽奖机——无JS,全靠现代CSS黑科技!
css·html
漂流瓶jz2 天前
BEM、OOCSS、SMACSS、ITCSS、AMCSS、SUITCSS:CSS命名规范简介
前端·css·代码规范
前端Hardy3 天前
HTML&CSS:高颜值产品卡片页面,支持主题切换
css·html
Never_Satisfied3 天前
在HTML & CSS中,nth-child、nth-of-type详解
前端·css·html