Incomplete circle using CSS with a separator in the middle with text

I am trying to make a circle divided by the center of some text. But can't find a solution using css.

My HTML:

<div class="wrap">
    <div class="left">
    </div>
    <div class="right">
    </div>
</div>

My CSS:

.right, .left {
    height: 200px;
    width: 200px;
    border: 1px solid #9F9F9F;
    float: left;
    margin: 2px;
}
.wrap {
    margin: auto;
    width: 420px;
    position: relative;
}
.left:after {
    content: "";
    display: inline-block;
    height: 60px;
    width: 6px;
    position: absolute;
    left: 203px;
    top: 65px;
    z-index: 99;
    background-color: #fff;
}
.right:before {
    content: "OR";
    border: 1px solid #9F9F9F;
    width: 50px;
    display: inline-block;
    border-radius: 50%;
    position: absolute;
    left: 175px;
    top: 65px;
    text-align: center;
    padding: 20px 5px;
}

Fiddle: https://jsfiddle.net/2re8d0cv/

My desired result:

It must be from

Having studied my code and the desired result, you will understand. I do not want to use the image there. since it will solve the problem, I cannot use the image. I want to do this only with full CSS, but I also don't know if this is possible or not.

+4
source share
2 answers

You can accomplish this by adding another pseudo-element so that the word “or” does not overlap with other elements.

.right:after, .right:before, , z-.

.

        .right:before {
            content:"";
            border: 1px solid #9F9F9F;
            width: 50px;
            height: 18px;
            display: inline-block;
            border-radius: 50%;
            position: absolute;
            left: 175px;
            top: 65px;
            text-align: center;
            padding: 20px 5px;
        }

       .right:after {
            content: "OR";
            width: 50px;
            display: inline-block;
            border-radius: 50%;
            position: absolute;
            left: 175px;
            top: 65px;
            text-align: center;
            padding: 20px 5px;
            z-index: 101
        }

: , , 1 1 pixel gap

, , .

, .right:after x, .left:before y.

            .left:before {
            content: "";    
            display: inline-block;
            height: 58px;
            width: 6px;
            position: absolute;
            left: 203px;
            top: 66px;
            z-index: 99;
            background-color: #FFF;
        }

.

image showing items

+3

SVG

, <SVG>

:

enter image description here

  • ( )
  • . , .

.wrapper {
  height: 400px;
}
.right {
  float: right;
  display: inline-block;
  width: 45%;
  height: 100%;
}
.circlebetween {
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  width: 20%;
  height: 100%;
  fill: white;
  stroke: #999;
  stroke-width: 0.7;
}
.left {
  float: left;
  display: inline-block;
  width: 45%;
  height: 100%;
}
<div class="wrapper">
  <div class="right">RIGHT</div>
  <svg class="circlebetween" viewBox="0 0 20 100" perserveAspectRatio="none">
    <path d="M 7,0 
               7,35
             A 15.1 15.1 0 0 0 7 65
             V100" />
    <path d="M13,0
             13,35
             A 15.1 15.1 0 0 1 13 65
             V 100" />
    <text x="50%" y="50%" dy=".3em" font-familiy="serif" stroke="none" fill="black" text-anchor="middle" transform="">OR</text>
  </svg>
  <div class="left">LEFT</div>
</div>
Hide result
+3

Source: https://habr.com/ru/post/1608714/


All Articles