GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — knowledge/css.md at master · AndCollectiom/knowledge

Expand file tree

/

css.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
120 lines (104 loc) · 3.75 KB
/

css.md

Copy path

File metadata and controls

120 lines (104 loc) · 3.75 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

CSS

New school CSS best practices. No SASS, just CSS. Best used with css-next or comparable.

Naming

Naming things is hard, and with specificity in the mix it becomes even harder. By using the naming scheme below, many, if not all naming issues will be resolved. Short words and dashes between them are key.

.navbar              block
.navbar-item         block-element
.navbar-item-active  block-element_modifier

Specificity

.foo .foo-bar .foo-bar_baz {}
.foo-bar_baz {}
[foo="bar"] {}

By using the second or third form, specificity issues will never happen.

Comments

Comments are useful to indicate new sections. Often times groups of selectors belong together, and comments are a great way to indicate that.

Variables

  • have a main color
  • light colors
  • dark colors
  • inverted colors
  • err, warn, success, action
  • have a complimentary color
  • head, body, mono fonts
  • z-indeces, colors, fonts are always a variable
  • variables for everything
  • all variables in one file

Flexbox

Flex container (parent):

display           flex, inline-flex
flex-direction    row, row-reverse, column
flex-wrap         nowrap, wrap, wrap-reverse
flex-flow         <flex-direction> <flex-wrap>
justify-content   flex-start, flex-end, center, space-between, space-around
align-items       flex-start, flex-end, center, stretch, baseline
align-content     flex-start, flex-end, center, stretch, space-between, space-around

Flex items (children):

order             <integer>
flex-grow         <integer:0>
flex-schrink      <ufloat:1.0>
flex-basis        <length> | auto
flex              none | <flex-grow> <flex-shrink> || <flex-basis>
align-self        auto, flex-start, flex-end, center, stretch, baseline

Files

Storing CSS in the right files is just as important as correctly naming classes. There are a few base files every site wants to start out with:

index.css       imports
vars.css        variable declarations
base.css        body classes & helpers, usually super tiny
typography.css  base text styles
buttons.css     base button styles
forms.css       base form styles
lists.css       base list styles

Attribute selectors

.show-grid [class*="span"] {} /* search children for class="span"*/
div[class^="something"] {}    /* search children for "begins with..." */
div[class$="something"] {}    /* search children for "ends with..." */
  • 30 selectors you must memorize
  • CSS3 selector substring matching

Print stylesheets

There are 2 approaches: blacklisting and whitelisting. Whitelisting is unwieldy to implement using CSS level 4, so blacklisting is the way to go.

whitelisting

Pick the elements you want to hide (sidebar, footer, etc) and set them to display: none.

  • print stylesheet approaches

Style input placholders

Supported by autoprefixer.

input::placeholder { }

source

Shadow

box-shadow: [horizontal offset] [vertical offset]
            [blur radius] [optional spread radius] [color];

natural looking components

  • flexy, resizable things
  • grab the border between 1 and 2, change the flex-grow property.
  • components need a certain order (flex -> relative -> absolute) or else the full width won't be covered.
---- ----
| 1| |2 |
---- ----

See also

  • medium's CSS coding guidelines
  • medium's CSS post thingy
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.