css - div with gradient background and rounded corners -


i've coded div gradient background , rounded corners:

#pill {     font-size: 12px;     height: 40px;     width: 100px;     margin: 0 20px 0 20px;     background: transparent;     background-image: linear-gradient(#080, #cf0 45%, #cf0 55%, #080);     z-index: 1;     text-align: center; }  #pill::before {     display: block;     content: '';     width: 40px;     height: 40px;     position: absolute;     margin-left: -20px;     z-index: -1;     border-radius: 40px;     background-image: radial-gradient(21px #cf0 5%, #080); }  #pill::after {     display: inline-block;     content: '';     width: 40px;     height: 40px;     position: relative;     top: -14.5px;     right: -50px;     z-index: -1;     border-radius: 40px;     background-image: radial-gradient(21px #cf0 5%, #080); } 

the result firefox, @ top zoom, one:

div gradient background , rounded corners

i'm not satisfied of way had use hardwired values, specially ::before element.

is there way, without jquery, make dynamic? tested css3 border-image-slice, looked promising, seems refuse radial-gradient border image.

more or less requested result, created shadow

you can play shadow parameters fine adjust it.

#test {      height: 40px;      width: 140px;    border-radius: 20px;    background-color: #cf0;    box-shadow: inset 0px 0px 14px 10px #080;  }      #pill {      font-size: 12px;      height: 40px;      width: 100px;      margin: 0 20px 0 20px;      background: transparent;      background-image: linear-gradient(#080, #cf0 45%, #cf0 55%, #080);      z-index: 1;      text-align: center;  }    #pill::before {      display: block;      content: '';      width: 40px;      height: 40px;      position: absolute;      margin-left: -20px;      z-index: -1;      border-radius: 40px;      background-image: radial-gradient(circle 21px, #cf0 5%, #080);  }    #pill::after {      display: inline-block;      content: '';      width: 40px;      height: 40px;      position: relative;      right: -50px;      z-index: -1;      border-radius: 40px;      background-image: radial-gradient(circle 21px, #cf0 5%, #080);  }
<div id=pill></div>  <div id=test></div>


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -