html - 如何获得弧形的div?

标签 html css reactjs

<分区>

我正在尝试创建一个包含引号的 div。此 div 需要呈弧形,即圆的 25%。

如何创建一个圆形的 div,但只使用其左上角 25% 的空间?

我试过 borderRadius 属性,它给出了一个完整的圆。

 <div
        style={{
          border: "1px solid black",
          height: "100px",
          width: "100px",
          borderRadius: "50%"
        }}
      >
        This is where the quotes will be printed
      </div>

如何让这个div变成弧形?例如这张图片中的第 7 个形状

Image demo

最佳答案

请看一下这个解决方案:

.quarter-circle {
    position: relative;
     width: 100px;
     height: 100px;
     background: none;
     border-left: 1px solid black;
     border-top: 1px solid black;
     border-radius: 100px 0 0 0;
     -moz-border-radius: 100px 0 0 0;
     -webkit-border-radius: 100px 0 0 0;
}

.text {
  position: absolute;
  top: 30px;
  left: 30px;
}
<div class="quarter-circle">
  <div class="text">
    This is where the quotes will be printed
  </div>
</div>

当然,您可以以任何其他方式移动文本,以适合您的设计。

Snippet external

关于html - 如何获得弧形的div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57570943/

相关文章:

html - CSS :Not attribute

html - 图像高分辨率不调整大小以适合 div

javascript - 为 Fullcalendar 中的特定时间段设置不同的颜色

javascript - 在 Bootstrap 导航栏中禁用新行

javascript - 在 React 中,根据之前和当前的 props,在哪里设置状态?

html - CSS 不对齐 Div 内的文本

html - Jekyll & KramDown - 如何显示表格边框

javascript - 菜单图标不显示在桌面版 Safari 中或根本不显示在移动设备上

javascript - 在 NextJs 的 getInitialProps() 中设置缓存控制 header

javascript - Reactjs 类型错误 : Cannot read property 'style' of undefined