Search code examples
cssbuttondivider

Putting Button within divider in css


I wanna implement this idea by css : enter image description here

What is the best approach to do that in CSS ? Thanks very much !!

UPDATE

I've did this trick before with Headings , More information here : Putting Heading within 2 horizontal lines in CSS

But when i tried to edit the heading version also didn't work with buttons .


Solution

  • http://jsfiddle.net/pB9MY/

    body { background: #fff;  }
    
    h3 {
      width: 500px;
      font: 30px Arial;
      font-weight: normal; 
      text-align: right;
      position: relative;
    }
    
    h3 span {
      background: #fff; 
      margin-right: 15%;
      padding: 0 20px;
    }
    
    h3:before {
      content: "";
      width: 100%;
      left: 0;
      top: 50%;
      position: absolute;
      z-index: -1;
      height: 0;
      border-top: 8px solid grey;
      opacity:.2
    }
    button{
      background-color:green;
      border:1px solid green;
      border-radius:5px;
      vertical-align:center;
    }
    
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=utf-8 />
    <title>JS Bin</title>
    </head>
    <body>
      <h3><span><button>Hello</button></span></h3>
    </body>
    </html>