Si8
Si8

Reputation: 9235

Why is the background image being cut off in a button

<a class="button icon tag" href="#"><span>Show All Tasks</span></a>

a.button {
    background-image: -moz-linear-gradient(top, #ffffff, #dbdbdb);
    background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #ffffff),color-stop(1, #dbdbdb));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#dbdbdb');
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#dbdbdb')";
    border: 1px solid #fff;
    -moz-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.4);
    -webkit-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.4);
    box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.4);
    border-radius: 3px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    padding: 10px 20px;
    text-decoration: none;
    text-shadow: #fff 0 1px 0;
    float: left;
    display: block;
    color: #597390;
    line-height: 24px;
    font-size: 20px;
    font-weight: bold;
    width: 100%;
}

a.button:hover {
    background-image: -moz-linear-gradient(top, #ffffff, #eeeeee);
    background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #ffffff),color-stop(1, #eeeeee));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#eeeeee');
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#eeeeee')";
    color: #000;
    display: block;
}

a.button:active {
    background-image: -moz-linear-gradient(top, #dbdbdb, #ffffff);
    background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #dbdbdb),color-stop(1, #ffffff));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#dbdbdb', EndColorStr='#ffffff');
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#dbdbdb', EndColorStr='#ffffff')";
    text-shadow: 0px -1px 0 rgba(255, 255, 255, 0.5);
    margin-top: 1px;
}

a.button.icon {
    padding-left: 0px;
}

a.button.icon span{
    padding-left: 100px;
    background: url(icons2.png) no-repeat 0 -4px;
}

a.button.icon.tag span {
    background-position: 0px -65px;
}

The Image (icons2 40X96):

enter image description here

How it is displayed in the browser:

enter image description here

How can I display the entire image so it doesn't cut off? Since it is just one image, how do I eliminate the user of position, rather just display the image?

Upvotes: 0

Views: 1410

Answers (2)

Jacob G
Jacob G

Reputation: 14172

Just give the span display:block; and height:30px;:

a.button.icon span{
    padding-left: 100px;
    background: url(https://i.sstatic.net/fEeuO.png) no-repeat 0 -4px;
    height:30px;
    display:block;
}

To stop the cut off, i changed the background position a little bit:

a.button.icon.tag span {
    background-position: 0px -62px;
}

enter image description here

JSFiddle

Upvotes: 2

knighter
knighter

Reputation: 1227

I would guess your line-height property is restricting how much of the image is shown. Also try adding overflow: visible to the icon's container.

Upvotes: 0

Related Questions