-
-
Save smuemd/0a35634cd5e6563354bdca2c0989be06 to your computer and use it in GitHub Desktop.
Sensible css defaults taken from css-layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div, span { | |
box-sizing: border-box; | |
position: relative; | |
display: flex; | |
flex-direction: column; | |
align-items: stretch; | |
flex-shrink: 0; | |
align-content: flex-start; | |
border: 0 solid black; | |
margin: 0; | |
padding: 0; | |
} |
via http://jsfiddle.net/vjeux/y11txxv9/
body {
padding: 0;
margin: 0;
font-family: Helvetica;
font-size: 14px;
font-weight: 100;
}
div, span {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
justify-content: flex-start;
border: 0 solid black;
margin: 0;
padding: 0;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taken from css-layout README:
Goals
CSSLayout is a cross-platform implementation of flexbox. The goal of CSSLayout is allow native developers to have the same expressive layout system as developers developing for the modern web are used to. CSSLayout allows developers for web, android, iOS, and windows to use the same layout primitives across platforms. This saves time, increases collaboration between platform teams, and makes it easier for developers to work on multiple platforms.
The goal of CSSLayout is not to re-implement all of css. CSSLayout only targets flexbox, and does not have any plans on implementing support for tables, floats, or any other css concepts. CSSLayout also does not plan on supporting styling properties which do not affect layout such as color or background properties.
Differences from web
CSSLayout tries to stay as close as possible to the web implementation of flexbox. There are however certain cases where CSSLayout differs from the web implementation.
Default values
CSSLayout has chosen to make changes to the default values of certain properties. These default values were chosen based on our usage of the library. When testing layout with tools such as JSFiddle you can apply the following css style to ensure the defaults match those of CSSLayout. Or fork the following JSFiddle.
box-sizing: border-box
is the most convenient way to express the relation betweenwidth
andborderWidth
.display: flex
by default. All the behaviors ofblock
andinline-block
can be expressed in term offlex
but not the opposite.position: relative
. This makesposition: absolute
target the direct parent and not some parent which is eitherrelative
orabsolute
. If you want to position an element relative to something else, you should move it in the DOM instead of relying of CSS. It also makestop, left, right, bottom
do something when not specifyingposition: absolute
.