What methods of ‘clearfix’ can I use?

Depending upon the design being produced, each of the below clearfix CSS solutions has its own benefits. The clearfix does have useful applications but it has also been used as a hack. Before you use a clearfix perhaps these modern css solutions can be useful: css flexbox css grid Modern Clearfix Solutions Container with overflow: … Read more

Align inline-block DIVs to top of container element

Because the vertical-align is set at baseline as default. Use vertical-align:top instead: .small{ display: inline-block; width: 40%; height: 30%; border: 1px black solid; background: aliceblue; vertical-align:top; /* <—- this */ } http://jsfiddle.net/Lighty_46/RHM5L/9/ Or as @f00644 said you could apply float to the child elements as well.

Can I combine :nth-child() or :nth-of-type() with an arbitrary selector?

This is a very common problem that arises due to a misunderstanding of how :nth-child(An+B) and :nth-of-type() work. In Selectors Level 3, the :nth-child() pseudo-class counts elements among all of their siblings under the same parent. It does not count only the siblings that match the rest of the selector. Similarly, the :nth-of-type() pseudo-class counts … Read more

In CSS Flexbox, why are there no “justify-items” and “justify-self” properties?

Methods for Aligning Flex Items along the Main Axis As stated in the question: To align flex items along the main axis there is one property: justify-content To align flex items along the cross axis there are three properties: align-content, align-items and align-self. The question then asks: Why are there no justify-items and justify-self properties? … Read more

Is there a CSS parent selector?

There is currently no way to select the parent of an element in CSS, at least not a way that works across all browsers. If there was a way to do it, it would be in either of the current CSS selectors specs: Selectors Level 3 Spec CSS 2.1 Selectors Spec That said, the Selectors … Read more

Pure CSS static starfield [closed]

As an exercise in “let’s see what happens if…” the following code was directly stolen from here and modified slightly to be static. The result is predictable: a basic, repetitive star field. <html> <head> <title>Testing a starfield</title> <style> #space, .stars { overflow: hidden; position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .stars … Read more