N
N
Nikita Titov2015-09-22 02:41:53
css
Nikita Titov, 2015-09-22 02:41:53

Why doesn't img want to be in a div?

913908672aea4fe099b4127aa37fcdac.png80918315612941cd9bd47248c917a5ba.pngcc06df04d1d14a5e93ff1edbbff6ef9a.png
I need this img to stand in the div to the "Book", and he got up under it and does not want to leave. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Faliah, 2015-09-22
@Faliah

First littleguga is right about the score

<div class=="book">, take one away

Secondly, I'll assume that it <img class=" right">sets the right alignment (float: right). When elements are aligned, they fall out of the flow and the parent element collapses to the height of the h2 tag in your case.
If my assumption is correct, then you need to use the (clear: both) property, it should look something like this:
.book:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
}

A zero-height block-level element will be added to the end of the content of the .book element to prevent it from collapsing.
See how it works here https://jsfiddle.net/zqww24ok/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question