css - Adding background image for Bootstrap list-group-item -
i have sprite i'm able display per each list-group-item
. however, i'm not able individually style each image .one, .two etc.
<div class="list-group"> <a href="#" class="list-group-item one">one</a> <a href="#" class="list-group-item two">two</a> <span class="list-group-item three">share <span class="fb"><!--display fb icon--></span></span> </div>
less: place text on left, align image on right side, works. want style individual images within each .list-group-item
. images repeat themselves, have position them on center of each anchor tag, , display pixel parts.
.list-group-item { width:100% height: 50px; float: left; overflow: hidden; text-align:left; background: url("sprite.png") right no-repeat; } .one { top:0; left:-15px;}
i tried adding images explicitly, this:
<div class="list-group"> <a href="#" class="list-group-item one">one<span class="img"></span></a> <a href="#" class="list-group-item two">two<span class="img"></span></a> <span class="list-group-item three">follow <span class="fb"><!--display fb icon--></span>/span> </div>
how can work?
i don't know want achieve supposed this:
.img{ float:right; display:inline-block; height: 44px; /*defines height portion of image want use*/ background: url('http://www.w3schools.com/css/img_navsprites.gif') 0 0; } #one{ width: 46px; /*defines width portion of image want use*/ background-position: 0 0; /*defines background position (left 0px, top 0px)*/ } #two{ width: 43px; background-position: -47px 0; /*defines background position 47px right (#one width 46px + 1px line divider)*/ } #three{ width: 43px; background-position: -91px 0; /*defines background position 91px right (#home width 46px + 1px line divider + #two width 43px + 1px line divider )*/ } .list-group-item{ overflow: hidden; }
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/> <div style="margin-bottom: 50px; text-align:center"> lets use image: <img src="http://www.w3schools.com/css/img_navsprites.gif" alt=""> </div> <div class="list-group"> <a href="#" class="list-group-item">one<span id="one" class="img"></span></a> <a href="#" class="list-group-item">two<span id="two" class="img"></span></a> <a href="#" class="list-group-item">three<span id="three" class="img"></span></a> </div>
so have move background position change portion of image want see.
anyway recommend use css sprite generator.
Comments
Post a Comment