Break line (clearfix)

Asked

Viewed 89 times

0

I would like to know, which forms you use when you need an element to occupy the total WIDTH+HEIGHT that it is using, for example:

<p>
    <span>Teste</span>
</p>

So that the P occupy the total size you are using, I usually use a class called cb, with the following properties:

.cb {
    clear: both;
    overflow: hidden;
}

or clearfix itself, however, I always wonder if there is a more organized way to do.

  • I don’t understand your question, the element <p> is already a block element, and so already assumes the entire size of its content (width + height)

  • I think the example was not very clear, but for example, if I had 2 SPAN’s inside P, and that float: left; in the same, the elements that came after P, would probably be in the same line as SPAN’s. To avoid this, I would use the CB class in the P.

  • 1

    Only the overflow: hidden that’s enough.

1 answer

1

Can do with float or with display: inline-block, or inline-table and if it is not floating from to use display: block.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.