문제

I've just created some articles in an HTML5 file. Those articles contain images. The articles also have a border at the bottom. Now I have this problem that whenever you re-size your window to make it larger, the images go outside the border. I want the border to re-size with the image.

Here's an example of how an article looks like in my page:

<article>
  <p>
    <img image />
  </p>
  <p>
    text
  </p>
</article>

The p-tag with the image inside floats left, the p-tag with text floats right next to it.

To be more clear: I want the article tag to resize to the height of the image.

도움이 되었습니까?

해결책

Just guessing, without seeing a working example or any of your CSS, but adding overflow: auto to the article element will cause it to contain its floated children:

article  {
  overflow: auto;
}

Example that may or may not relate to the CSS we can't see: http://codepen.io/paulroub/pen/opnfG

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top