1

I want to put one image and one block with two

in one line, but if use float on image, it will be out of that big block' border. I don't want to add height to the big block, because sometimes image doesn't exit. like this link: images and (p1 + p2 ) in one line. http://verygif.com/bbs/b/src/138002270032.jpg sorry for can't post images.

big_block {
border:2px solid #333;
}


<div class="big_block">
{if img exit }<img .... />{/if}
<p>sometext,sometext,sometext,sometext</p>
<p>fulltext,fulltext,fulltext,fulltext</p>
</div>
Praveen04
  • 985
  • 10
  • 12
longnight
  • 162
  • 2
  • 11

3 Answers3

2

Just declare overflow: hidden; on the parent <div> container. That will clear the float and ensures that the image does not go beyond the parent's borders by ensuring that the parents wrap around the paragraphs AND the image.

See example here: http://jsfiddle.net/teddyrised/8aeAL/

Terry
  • 63,248
  • 15
  • 96
  • 118
0

You can try using display: inline to <p> tags,

p { 
  margin: 0; 
  padding: 0; 
  display: inline; 
} 

Check this http://jsfiddle.net/tpD2u

Ashis Kumar
  • 6,494
  • 2
  • 21
  • 36
0

I always use something like this:

.big_block img { float: left; }
.big_block:after { display: block; cler: both; content: " "; }

http://jsfiddle.net/QWm4T/