Thursday, 15 January 2015

css - Re-size background image -



css - Re-size background image -

i have slider , works loading in background image. need resize image fits screens know line of code need set in don't quite know how go it. need add together

background-size: 100% 100%;

to $style variable, how go doing this.

i tried

$style = "background-size: 100% 100%;, background:url('". mage::getbaseurl('media') . $s['image'] . "') 50% 0 no-repeat;";

but loaded background size not background.

<ul class="slides"> <?php $slides = $this->getslides(); foreach($slides $s) { $style = $content = ''; $attr = 'data-img-height="0"'; if ( !empty($s['image']) ) { $imgsize = getimagesize(mage::getbasedir('media') .'/'. $s['image']); if ($imgsize) { $style = "background:url('". mage::getbaseurl('media') . $s['image'] . "') 50% 0 no-repeat;"; $attr = 'data-img-height="'.$imgsize[1].'"'; } }

by default background-size initial (which in fact auto). when using background background-related settings before including background-size overridden default value or value set in background declaration. should place background-size after background declaration. or set background-image, background-position, background-repeat, ... separately in order want.

css

No comments:

Post a Comment