Nikola242016-11-06 21:22:38
Nikola24, 2016-11-06 21:22:38

::after only works on 'content', why?

I tried to test one thing, after two float blocks, set :after with clear:both, but for some reason nothing happens if I add content: "text"; then everything works right away. Why is this happening?

<main class="clear">
    <div class="first"></div>
    <div class="second"></div>
  <div class="three"></div>

    background-color: red;
    display: block;
    width: 50px;
    height: 50px;
    margin: 20px;
    float: left;
    float: right;
    background-color: blue;
    width: 200px;
    clear: both;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Elwen, 2016-11-06

:before and :after are only used in conjunction with content. To create an empty pseudo element add content: " "orcontent: "\00a0"

KlassT, 2016-11-06

css standard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question