css - Unable to use calc to size image in carousel -
i'm hoping simple answer i'm overlooking. i've been toying around ui-bootstrap carousel directive, , wanted size dynamically fill space between header , footer.
my header , footer each divs 70px in height. carousel works fine when let it's own thing, , plug images in. images rather large , not same size. thought maybe issue img
tag changed div
, set images background of each 1 height set calc(100% - 70px - 70px)
. div's never seem calculated height (they have height of 0).
after searching online, have set html
, body
tags height: 100%
already, isn't issue.
given it's kind of hard explain, please reference this plunkr
heights given percentages work if parent element has explicit height set – don’t have here, can’t work, whether used in calc()
or height: x%
directly.
but of course use calc(100vh - 140px)
, if ok limited support in older browsers¹. 100vh
100% of viewport height, doesn’t need have height set on parent elements html
element (as height:100%
require achieve same thing).
¹ aware known issues @ caniuse mention “safari & ios safari (both 6 , 7) not support viewport units […] in calc().” depending on whether need those, might deal breaker. in case, might try , go absolute (or fixed) positioning (70px top
, bottom
each) carousel container. way, have defined height again, , 100% child elements should work.
Comments
Post a Comment