css - Resize image keeping both sizes on ratio -
i have photo blog on final stages , last problem i'm struggling with. layout has fixed menu bar on right , content flows on right. when photo opened gallery page it's own, supposed resized either side not on (for example) 70% of free space. not that. should stay in horizontal , vertical center of right content div. @ point works except when image portrait goes on screen.
is possible achieve css please few percent has js not activated? if not, thats not deal breaker.
the html:
<div id="wrapper"> <div id="left_column"> </div> <div id="right_column_post"> <div id="post_container"> <img src="img.jpg" width="1000" height="750"/> </div> </div> </div>
the css:
#left_column { position: fixed; top: 0; bottom: 0; left: 0; z-index:100; width: 240px; height: 100%; overflow: hidden; } #right_column_post{ height: 100%; width:auto; margin-left:240px; position: relative; } #post_container { width:100%; height:100%; display: block; vertical-align: middle; text-align:center; } #post_container:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* adjusts spacing */ } #post_container img{ max-width:70%; height:auto; display: inline-block; vertical-align: middle; margin:auto; position:relative; }
this close: http://jsfiddle.net/jcagj/ it'll break layout if implemented is.
i not sure looking for, if want resize image in aspect ratio not give max-width , max-height both, if u @ point loose aspect ratio.
u can give width:100%;
here giving width in percentage
#left_column { position: fixed; top: 0; bottom: 0; left: 0; z-index:100; width: 40%; height: 100%; overflow: hidden; background:red; } #right_column_post{ height: 100%; width:50%; margin-left:45%; position: relative; } #post_container { width:90%; height:100%; display: block; vertical-align: middle; text-align:center; } #post_container:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* adjusts spacing */ } #post_container img{ width:100%; max-width:100%; display: block; vertical-align: middle; margin:0 auto; position:relative; }
check link: /new link/
http://jsfiddle.net/madhuri2987/jcagj/2/
hope u looking for.
Comments
Post a Comment