twitter bootstrap - responsive css background property -
i have markup :
<ol class="carousel-indicators"> <li data-target="#showcarousel-03" data-slide-to="0" class="active"> <h4>title</h4><br/><h5>text</h5><br/><span>+</span> </li> <li data-target="#showcarousel-03" data-slide-to="1"> <h4>title</h4><br/><h5>text</h5><br/><span>+</span> </li> <li data-target="#showcarousel-03" data-slide-to="2"> <h4>title</h4><br/><h5>test</h5><br/><span>+</span> </li> <li data-target="#showcarousel-03" data-slide-to="3"> <h4>title</h4><br/><h5>text</h5><br/><span>+</span> </li>
and css :
.carousel-indicators li{ display:block; float:left; background: url(images/triangle.png) no-repeat; width:320px; height:176px; cursor: pointer; text-align:center; }
and container div of markup have width set 100%
on actual resolution (1366px wide) li elements aligned good, when resize browser elements not aligned.
i'm using twitter bootstrap framework.
my question how can make elements scale when resolution lower?
thanks!
for responsive design use bootstrap grid system in carousel adding proper class code .span4
.span8
etc. resize carousel browser size, grid system has fixed size might not fit needs. need overwrite sizes own css may hard handle if use grid system in site.
this doc site grid system
second approach use em
or %
carousel elements size , body element. media queries http://www.w3.org/tr/css3-mediaqueries/ can set how carousel changes in lower resolutions. 1 em equal 16px. calculation of new em size bit tricky, divide 1
parent container size, whitch body element 16px
font-size , multiply current px
size:
1/16px*320px = 20em
css:
body { font-size:1em; /* 16px */ } .carousel-indicators li{ display:block; float:left; background: url(images/triangle.png) no-repeat; width:20em; /* 1/16px*320px = 20em */ height:11em; /* 1/16px*176px = 20em */ cursor: pointer; text-align:center; }
tip. if want background image scalled use background-size
property well.
background-size:20em 11em;
size screen lower 1170px:
@media (max-width:1170px){ body { font-size: 0.875em; /* 14px */ } @media (max-width:800px){ body { font-size: 0.75em; /* 12px */ }
your li
element width automaticaly change 0.875em*20em = 17.5em
in resolution lower 1170px , 0.75em*20em = 15em
in resolution lower 800px.
hope helps!
Comments
Post a Comment