Search code examples
cssbuttonborderuniqueoutline

How to make a button with outline of a dog bone using css?


I looked for this but couldn't find it. I am making a pet care website and I want to make some of the buttons in the shape of a bone while still functioning like a normal button (hover functions). Instead of a rounded or rectangular shaped button is there any way to make the outline into the shape of a bone?

Thank you!


Solution

  • If you don't want to use an image here's an example made only with HTML and CSS.

    .bone{
      margin: 20px;
      position: relative;
      width: 150px;
      height: 60px;
      cursor: pointer;
      background: transparent;
      border: none;
    }
    .c1, .c2, .c3, .c4{
      background:#fff;
      height: 30px;
      width: 30px;
      border: 1px solid #000;
      border-radius: 50%;
      position:absolute;
    }
    .c1{
      left: 0;
      top: 0;
    }
    .c2{
      right: 0;
      top: 0;
    }
    .c3{
      left: 0;
      bottom: 0;
    }
    .c4{
      bottom: 0;
      right: 0;
    }
    .b1 {
      background:#fff;
      height: 30px;
      width: 120px;
      position:absolute;  
      left: 15px;
      top: 15px;
    }
    .b2 {
      position: absolute;
      left: 15px;
      top: 0;
      width: 90px;
      height: 30px;
      line-height: 30px;
      border-top: 1px solid black;
      border-bottom: 1px solid black;
      text-align: center;
    }
    <button class="bone">
        <div class="c1"></div>
        <div class="c2"></div>
        <div class="c3"></div>
        <div class="c4"></div>
        <div class="b1">
          <div class="b2">
            Button Text
          </div>
        </div>
    </button>