D
D
Denis Sopko2018-11-30 19:58:27
Layout
Denis Sopko, 2018-11-30 19:58:27

Scss question. Why such investment?

There is a block with the class "header" and a child block with the class "wr". Now I'm watching a video on page layout on scss (it doesn't matter why) and that's the question. I've just started learning sass/scss and I know to refer to the child element of the "header" block, you can refer to it like this:

.header{
    code...
        .wr{
        width: 110px;
        }
}

================================================= ==========
But the author of the video writes like this:
.header{
    code...
        &>.wr{
        width: 110px;
        }
}

====================
I know that the ampersand sign is a string (characters) binding to the parent element, but why is that? There is no need for binding here. After all, it was necessary to write like the first option5c016c2db6c0a364730245.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Koryukov, 2018-11-30
@denisopko

In the first variant, it turns out that an element with the wr class can be arbitrarily deep inside the header.
In the second - only directly in the header, but not in the child elements of the header.
It's possible to start a nested element with >, but that's not certain.
In general, here the question is already to the author of this code, because there are many working options, and the first one will also work, but the author additionally set such a restriction, and perhaps he was just playing it safe.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question