skip to Main Content

I am wondering if possible to create the following button element with css?

Radial button

I have created the radial button using svg but it is not dynamic enough.
Ill be glad for any suggestions or similar examples to help me convert it to css.

I want to be able to resize the inner radius dynamical.

<svg data-name="Component 10 – 2" xmlns="http://www.w3.org/2000/svg" width="46.334" height="70.626" viewBox="0 0 46.334 70.626">
   <g data-name="Path 613" style="fill:#474747;opacity:.9">
       <path d="m130.337 99.172-17.411-10.34a26.173 26.173 0 0 0 2.708-11.577 26.032 26.032 0 0 0-24.113-26.042V30.965a45.858 45.858 0 0 1 16.653 3.88 46.313 46.313 0 0 1 14.415 9.988 46.272 46.272 0 0 1 9.71 14.62 45.937 45.937 0 0 1 3.556 17.802 46.32 46.32 0 0 1-5.518 21.917z" style="stroke:none" transform="translate(-90.521 -29.933)"/>
       <path d="M129.94 97.774a45.333 45.333 0 0 0 4.915-20.519c0-6.031-1.17-11.891-3.48-17.417a45.276 45.276 0 0 0-9.5-14.304 45.317 45.317 0 0 0-14.105-9.775A44.828 44.828 0 0 0 92.52 32.02V50.3c13.668 1.493 24.113 12.983 24.113 26.955 0 3.853-.83 7.682-2.415 11.182l15.721 9.337m.773 2.785L111.604 89.21a25.09 25.09 0 0 0 3.03-11.955c0-13.515-10.727-24.571-24.113-25.098V29.933c25.64.535 46.334 21.558 46.334 47.322a47.25 47.25 0 0 1-6.142 23.304z" style="fill:#ff2238;stroke:none" transform="translate(-90.521 -29.933)"/>
   </g>
</svg>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="44px" height="44px" viewBox="0 0 44 44" enable-background="new 0 0 44 44" xml:space="preserve">
<g>
    <path opacity="0.8" fill="#0A0A0A" d="M0.5,43.502h20.998c0-12.422,10.08-22.501,22.502-22.501V0C19.986,0,0.5,19.485,0.5,43.502z"
        />
    <polygon opacity="0.5" fill="#FFFFFF" points="44,21.001 43,21.001 43,0 44,0 44,21.001   "/>
    <polygon points="21.499,42.482 21.5,43.482 0.501,43.502 0.5,42.5 21.499,42.482  "/>
</g>
</svg>

2

Answers


  1. I think you could approach this using something this vein, making an arc shape and turning it on its side – then you could use a similar positioning to the text. Hope this helps!

    .quarter-circle {
      position: relative;
      width: 80px;
      height: 80px;
      background: none;
      border-left: 30px solid black;
      border-top: 30px solid black;
      border-radius: 100px 0 0 0;
      -moz-border-radius: 100px 0 0 0;
      -webkit-border-radius: 100px 0 0 0;
      transform: rotate(-30deg);
    }
    
    
    Login or Signup to reply.
  2. I don’t know if you find this useful. Here are two examples on how you can change an SVG using CSS hover. I use circles because they are simpler to style using CSS.

    #g1 circle {
      transition: all .3s;
    }
    
    #g1:hover circle:nth-child(1) {
      stroke-dasharray: 180 360;
      stroke-dashoffset: 0;
    }
    
    #g1:hover circle:nth-child(2) {
      stroke-dasharray: 0 2 176 360;
      stroke-dashoffset: 0;
    }
    
    #c2 {
      transition: all .3s;
    }
    
    #c2:hover {
      r: 60px;
      stroke-width: 80px;
    }
    <p>Transition stroke-dasharray on hover:
    <svg xmlns="http://www.w3.org/2000/svg" width="50" viewBox="0 0 65 100">
      <g transform="translate(15 50)">
        <g id="g1" transform="rotate(-105)" fill="none">
          <circle r="35" stroke-width="30" stroke="#ff2238" stroke-dasharray="135 360"
            pathLength="360" stroke-dashoffset="-15"/>
          <circle r="35" stroke-width="26" stroke="#575757" stroke-dasharray="0 2 131 360"
            pathLength="360" stroke-dashoffset="-15"/>
        </g>
      </g>
    </svg>
    </p>
    <p>Transition radius and stroke-width on hover:
    <svg xmlns="http://www.w3.org/2000/svg" width="50" viewBox="0 0 100 100">
      <circle id="c2" transform="translate(100 100) rotate(180)" r="75" stroke-width="50"
      stroke="#0A0A0A" fill="none" stroke-dasharray="90 360" pathLength="360" opacity=".8" />
    </svg>
    </p>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search