html - CSS div height percent not working -


so have img #anniversary-img inside div #anniversary-img-container. want have img resize automatically (with max size being 15em 15em) resize browser window (to accommodate smaller displays such phones). have tried many things using percent height doesn't affect @ all.

jsfiddle

html

<div class ="col1-sec sec" id="col1-sec1">   <div id="anniversary-container">     <h2>welcome</h2>     <div class="img-container" id="anniversary-img-container">       <img src="images/anniversary-img.jpg" width="862" height="840" alt="celebrating 60 years of catholic service" id="anniversary-img" />     </div><!-- end #anniversary-img-container -->     <div id="contact-container">       <p>1450 w. la venture avenue<br />las vegas, nv 12345-0000</p>       <p><span class="contact-text">phone</span> 123-456-7890</p>       <p><span class="contact-text">fax</span> 123-456-7890</p>       <p><span class="contact-text">email</span> <a href="mailto:me@yahoo.com">me@yahoo.com</a></p>     </div><!-- end #contact-container -->   </div><!-- end #anniversary-container --> </div><!-- end #col1-sec1 --> 

css

.sec, .img-container {     border: 1px solid #d8d8d8;} #col1-sec1 {     height: 100%;     overflow: auto;} #anniversary-container {     overflow: auto;     width: 100%;} #anniversary-img-container {     height: 15em;     width: 15em;     margin-left: 2em;     margin-bottom: 1em;     float: left;} /* make container proportionate img */ #anniversary-img {     max-width: 100%;     max-height: 100%;} #contact-container {     width: 40%;     float: right;     margin-right: 5em;     margin-top: 2em;     text-align: left;} .contact-text {     font-weight: bold;} 

edit: solved removing height & width (of #anniversary-img) in html file , setting:

#anniversary-img-container {     max-height: 15em;     max-width: 15em;} 

you use background-image image-container, gives more control on behaviour of image. here- http://jsfiddle.net/mpx6vml4/2/

#anniversary-img-container {     height: 15em;     width: 15em;     margin-left: 2em;     margin-bottom: 1em;     float: left; /* make container proportionate img */     background: url(images/anniversary-img.jpg) no-repeat; /*center center maybe?*/     background-size: cover; /*contain or custom value*/ }  /* #anniversary-img {     max-width: 100%;     max-height: 100%;} */ 

try play background attributes.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -