html - How can I get div container to resize vertically the same as image? -
i have been trying since last night code seems worse more try. wanted try , build responsive image slider, reason decided use ul so. isn't needed problem same. resize browser window make narrower, image resizes vertically, div container not. have tried percentages, pixels, vh values, max-heights etc nothing works make container resize in propotion image inside. container named .slide have made jsfiddle
.slider { width : 100% ; height : 100% ; position : relative ; padding : 0 ; margin : 0 ; background : green } .slide { background-color : #fafafa ; width : 30% ; margin : auto ; height : 50% ; min-height : 330px ; position : relative ; top : 30% ; right : 0 ; left : 0 ; bottom : 0 } .slide ul { list-style : none ; } .slide ul li { position : absolute ; left : 18% ; right : 18% ; top : 16% } ul li img.photos { width : 100% }
it because in following code have set min-height: 330px
not allow container resize vertically. decrease height: 50%;
see not need 50% height.
i suggest use min-height
, min-width
image.
.slide { background-color : #fafafa ; width : 30% ; margin : auto ; height : 50% ; min-height : 330px ; position : relative ; top : 30% ; right : 0 ; left : 0 ; bottom : 0 }
the second possibility rid of div , use border , padding image have white background in behind.
Comments
Post a Comment