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>
相关推荐
XboxYan1 小时前
CSS 小技巧:如何将 img 转换成 background-image
前端·css
复苏季风3 小时前
前端居中布局:从 "卡壳" 到 "精通" 的全方位指南
前端·css
前端呆猿14 小时前
深入解析HTML5中的object-fit属性
前端·css·html5
路灯下的光16 小时前
用scss设计一下系统主题有什么方案吗
前端·css·scss
一只小风华~16 小时前
CSS @media 媒体查询
前端·css·媒体
复苏季风1 天前
CSS 布局小技巧:用 padding 撑开 div 不香吗?
css
不死鸟.亚历山大.狼崽子1 天前
Syntax Error: Error: PostCSS received undefined instead of CSS string
前端·css·postcss
不在了情绪1 天前
CSS 基础语法 + 弹性盒子
前端·css
狂炫一碗大米饭2 天前
每个前端开发人员都应该知道的 6 大 CSS 框架
css·scss
惜分飞2 天前
ORA-600 kcratr_nab_less_than_odr和ORA-600 2662故障处理---惜分飞
前端·css·less