F
F
freeman02042015-10-10 20:42:35
css
freeman0204, 2015-10-10 20:42:35

Why use box-sizing: border-box; with pseudo classes?

Why use box-sizing: border-box; with pseudo classes?

*,
*:before,
*:after {
  box-sizing: border-box;
}

why not just write
* {
box-sizing: border-box;
}

??

Answer the question

In order to leave comments, you need to log in

13 answer(s)
D
Dmitry, 2015-10-10
@mytmid

open this code in a browser:

<!DOCTYPE html>
<html>
    <head>
        <title>test</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style type="text/css">
            * {
                box-sizing: border-box;
            }
            
            div{
                display: block;
                height: 50px;
                width: 100px;
                border: 5px solid #000;
                margin: 5px;
                padding: 5px;
            }
            div:after{
                content: "after";
                display: block;
                height: 100px;
                width: 100px;
                border: 5px solid #000;
                margin: 5px;
                padding: 5px;
            }
        </style>
    </head>    
    <body>
        <div>test</div>
    </body>
</html>

and then replace:
* {
    box-sizing: border-box;
}

to this:
*, *::after {
    box-sizing: border-box;
}

...and refresh the page.
And it will immediately become clear why:
* {box-sizing: border-box;} does not affect the behavior of ::after and ::before

I
Ivanq, 2015-10-10
@Ivanq

* does not include ::after and ::before

G
GoodProject, 2015-10-10
@GoodProject

As far as I know, box sizing's cross-browser compatibility is not ideal

T
TheHorse, 2012-07-23
@TheHorse

No, they couldn't. You don't need links, you need books. Do you have preferences for languages/directions?
Fundamental Algorithms — T. Kormen “Algorithms. Construction and analysis.»

Z
zoo, 2012-07-23
@zoo

S. McConnell. Perfect Code is a very interesting book.

W
winbackgo, 2012-07-23
@winbackgo

Programming is learned by programming.

U
Unhandled_Exception, 2012-07-23
@Unhandled_Exception

Let them consider me old-fashioned, but I would recommend taking Knuth:
en.wikipedia.org/wiki/The
Art_of_Programming lib.ru/CTOTOR/KNUT/

D
Dmitry, 2012-07-26
@Neir0

By C#:
Richter CLR via C#. — About working “at a low” level (garbage collector, reference and value types etc)
John Skeet C# in depth. - C# advanced level.
Joseph Albahari C# in nutshell - Middle
Algorithms, as already suggested by Corman + Stanford course. or Mitovsky. In short, the one in which everything is systematically stated. + it is desirable to come up with a practical task for consolidation.
By Design Patterns:
Gang of Four and Fowler Classics
By specific technologies:
asp.net mvc - Stephen Sanderson's book, at the same time you can see his blog and knockoutjs, his js library included in asp.net mvc
WPF - Matthew McConnell (if I remember correctly)
T-SQL - I liked the T-SQL Fundamentals book from Microsoft Press, alas, I can’t recommend something more advanced.

D
Dmitry, 2012-07-27
@EvilsInterrupt

I also recommend developing problem solving skills. This is if it is abstract, but if it is substantive, then I recommend looking around you at acquaintances / friends / colleagues / relatives or anyone else and see the one you respect for the fact that he can solve almost any problem.
The fact is that he gets a lot, and lives well, who can solve problems and solve them correctly, efficiently and with less losses, both financial and temporary.
It’s hard for me to recommend a book on developing such skills, but such skills need to be pumped regularly.

A
Anatoly, 2012-07-23
@taliban

An algorithm is a certain sequence of actions. Nothing good will come from studying a couple of algorithms, no one will learn to program. Books should be read as much as possible and work, applying knowledge from books (articles).

M
Morozov_5F, 2012-07-23
@Morozov_5F

But for what they downvote and cut off karma - I don’t understand. Has no one ever asked for advice on where to start?

Y
Yizakhi, 2012-07-23
@Yizakhi

I would also "advise" reading SICP, Dragon Book and Design Patterns. For symmetry to Knuth, McConnell and Cormen :).

A
AWE64, 2012-07-26
@AWE64

At this link , you can get basic knowledge about programming under WinAPI and DirectX in C ++. Written, it seems, with the expectation of absolute beginners (but it's hard for me to judge this, since at the time of reading I already had experience programming under DirectX in Delphi). An explanation is given of some nuances that can initially cause difficulties that are not explained in old textbooks (using Unicode, for example).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question