html - inline-block object not resizing properly with dynamically sized image -



html - inline-block object not resizing properly with dynamically sized image -

i trying center set of floated blocks contain images scale dynamically. having issue inline-block using come in floated blocks not shrinking new size of image. instead wrap original size of image, leaving big empty space.

http://jsbin.com/ewonas/1/

body { text-align: center; } .inlineblock { background: red; display: inline-block; } .constrainer { width: 20%; float: left; } .constrainer img { width: 100%; } <body> <div class="inlineblock"> <div class="constrainer"> <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/smiley.svg/500px-smiley.svg.png"> <h1>product title</h1> </div> <div class="constrainer"> <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/smiley.svg/500px-smiley.svg.png"> <h1>product title</h1> </div> </div> </body>

can please help me prepare issue?

thanks

you setting width of 2 .constrainer divs 20%. means width 20% of parent .inlineblock. when have 2 of them adds 40% of parent. means have 60% remaining, or space 3 .constrainer divs.

to create .inlineblock element shrink down, need set width of .constrainer divs number independent of parent e.g. fixed width 300px instead of percentage.

live example: http://jsbin.com/ewonas/6

html image css

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -