html - css:使div变圆并在其3/4处添加边框

标签 html css

我有这样的代码:

<div class="circle"></div>


和CSS:

.circle {
 border-left: 1px solid red;
 border-bottom: 1px solid red;
 border-radius: 200px;
 width: 200px;
 height: 200px;
}


但我得到这样的边界:

enter image description here

我怎样才能获得直线和圆形的边界?

我的意思是这样的:

enter image description here

CSS有可能吗?

最佳答案

SVG圈子

用svg创建一个3/4的圆只是几行代码:



#cut-circ {
  stroke-dasharray: 110;
  stroke-dashoffset: 0;
}

<svg id="cut-circ" viewBox="0 0 100 100">
  <circle cx="50" cy="50" r="23" stroke="red" fill="gray" />
</svg>





或CSS



.circ {
  border-radius: 50%;
  width: 150px;
  height: 150px;
  display: inline-block;
  background-color: gray;
  border-top: 3px solid transparent;
  border-left: 3px solid red;
  border-right: 3px solid red;
  border-bottom: 3px solid red;
  transform: rotate(45deg);
}

<div class="circ"></div>






如果我的文字有内部间距怎么办?


带有文本的svg圈



#cut-circ circle {
  stroke-dasharray: 110;
  stroke-dashoffset: 0;
}
#cut-circ text {
  font-size: 10px;
  transform: translate(-13px, 2.5px);
}

<svg id="cut-circ" viewBox="0 0 100 100">
  <circle cx="50" cy="50" r="23" stroke="red" fill="gray" />
  <text x="50" y="50">Foobar</text>
</svg>





CSS圆与文本



.circ {
  border-radius: 50%;
  width: 150px;
  height: 150px;
  display: inline-block;
  background-color: gray;
  border-top: 3px solid transparent;
  border-left: 3px solid red;
  border-right: 3px solid red;
  border-bottom: 3px solid red;
  transform: rotate(45deg);
}
.circ span {
  display: inline-block;
  transform: rotate(-45deg) translate(-10px, 70px);
  font-size: 2em;
}

<div class="circ">
  <span>Typo</span>
</div>

关于html - css:使div变圆并在其3/4处添加边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38061969/

相关文章:

javascript - 如何用 Flot 显示空白图形

javascript - 如何仅使用 javascript 在 html 选择选项中列出 JSON 文件中的对象?

php - 在 PHP 中使用 if 语句和 $GET 的正确方法

html - CSS Sprite 不起作用,因为宽度/高度定义了容器

html - 当我开始动画时,CSS Border 将文本向下移动

html - 如何更改整个页面的默认滚动条而不仅仅是在一个 div 内

javascript - 在不重定向的情况下在 DIV 中加载页面

html - 如何使用 CSS 自动将 » (») 添加到 <li> 元素?

html - 如何将 2 个 SVG 并排放置在容器中并调整容器的高度?

jquery - 如何制作JQuery + CSS垂直制表符