css - What other means are available to crop/clip a background image if :pseudo elements are not available? -


i have button multiple backgrounds. 1 of backgrounds css-sprite (864px x 18px) containing icons.

i'm trying add background <input> element make button icon. problem is, can't use :before/:after because inputs have no content, cannot add element, specify it's proportions , use background-size/position.

here have:

.buttonupinput {     background: rgba(0, 0, 0, 0.4), #7eb238;     background-image: none; /* fallback */     background-image: url("http://mysprite.png"), -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(rgba(52,109,28,1)), color-stop(rgba(52,109,28,0) )), -webkit-gradient(linear, left top, left bottom, from( #9ad945 ), to( #7eb238 ));      background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -webkit-radial-gradient(center, ellipse cover,  rgba(52,109,28,1), rgba(52,109,28,0) ), -webkit-linear-gradient( #9ad945, #7eb238 );      background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -moz-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -moz-linear-gradient( #9ad945, #7eb238 );      background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -ms-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -ms-linear-gradient( #9ad945, #7eb238 );      background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -o-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -o-linear-gradient( #9ad945, #7eb238 );      background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), radial-gradient(ellipse @ center, rgba(52,109,28,1) 67%, rgba(52,109,28,0) 69%), linear-gradient( #9ad945, #7eb238 );     background-attachment: scroll, scroll, scroll;     background-repeat: no-repeat, no-repeat, no-repeat;     background-position: -100px 50%, 7px 50%, center center;     background-size: 864px 18px, 20px 20px, auto auto;     background-clip: content-box, content-box, padding-box;     border: 1px solid #aaa;     -moz-border-radius: .7em;     -webkit-border-radius: .7em;     border-radius: .7em;     color: white !important;     font-size: 16px;     font-weight: 800;     padding: 2px 14px 4px 1px;     text-indent: 35px;     width: auto;     height: 2.25em;     cursor: pointer; }  

question:
try hardcode/tweak button size/width (which i'd prefer being flexible) try , use content-box/padding-box, can't work. i'm wondering if there other means achieve css only?

thanks!

there's pretty nothing can crop background that. svg sprite stacks close can get, support poor.

however, change input button element:

http://jsfiddle.net/5ugwe/

button:before {     content: ' ';     width: 50px;     height: 50px;     background: url(http://placehold.it/50x50);     display: inline-block;     vertical-align: middle; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -