html - border curved css - 带 flex 端的圆

标签 html css svg border css-shapes

我正在建立一个网站,但我很难用 CSS 做细节

我需要制作一个末端 flex 的圆形边框,为了让您更好地理解,我会展示照片并发布我的代码

我需要什么 (Photoshop)

enter image description here

enter image description here

我想要一个 CSS 解决方案,但我做不到。

这是我实际拥有的:

.bottom-bar {
  background: #29a7e8;
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50px;
  text-align: center;
}

.circle {
  display: inline-block;
  position: relative;
  top: -10px;
  border-radius: 100%;
  background: #29a7e8;
  width: 60px;
  height: 60px;
  margin: 0 1rem;
}
<div class="bottom-bar">
      <div class="circle"></div>
      <div class="circle"></div>
      <div class="circle"></div>
    </div>

最佳答案

您可以使用 SVG 作为背景来做到这一点:

.bottom-bar {
  background: #29a7e8;
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50px;
  text-align: center;
}

.circle {
  display: inline-block;
  position: relative;
  top: -28px;
  border-radius: 100%;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='10 10 45 15'  width='64' height='64' fill='%2329a7e8'><path d='M12 24 L52 24 L52 16 C40 16 42 10 32 10 C20 10 22 16 12 16 Z' /></svg>") 0 0/100% 100% no-repeat;
  width: 60px;
  height: 60px;
  margin: 0 1rem;
}
<div class="bottom-bar">
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
</div>


<svg xmlns='http://www.w3.org/2000/svg'
  viewBox='10 10 45 15'
  width='64' height='64'
  fill='#29a7e8'>
  <path d='M12 24 L52 24 L52 16 C40 16 42 10 32 10 C20 10 22 16 12 16 Z' />
</svg>

对于纯 CSS 解决方案,您可以考虑结合径向渐变来创建曲线:

.bottom-bar {
  background: #29a7e8;
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50px;
  text-align: center;
}

.circle {
  display: inline-block;
  position: relative;
  top: -30px;
  background:
  radial-gradient(circle at top right,transparent 50%,#29a7e8 51%)100% 21px/12px 10px no-repeat,
  radial-gradient(circle at top left,transparent 50%,#29a7e8 51%)0 21px/12px 10px no-repeat,
  radial-gradient(circle at center,#29a7e8 55%, transparent 56%);
  width: 60px;
  height: 60px;
  margin: 0 1rem;
}
<div class="bottom-bar">
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
</div>

关于html - border curved css - 带 flex 端的圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57652615/

相关文章:

android - 应用程序开发

javascript - 我可以使用indexedDB来存储sipml5客户端对象吗

c# - 如何使用 C# 在 MVC 布局 View 中编辑 CSS 类

html - 调整图像大小并添加叠加图像而不使用表格并且不会丢失 xml 中的样式

javascript - 如何将 SVG 的背景颜色正确转换为 Canvas

html - 导航栏的 CSS 帮助

javascript - 在 WordPress 的页面模板中设置动态文本

css - bootstrap 3 row-same-height 不起作用

svg - 为什么SVG笔画宽度为: 1 making lines transparent?

javascript - c3.js如何将y标签放置在水平条形图中的条形内?