BEM is a methodology for naming and classifying CSS selectors in a way to make them a lot more strict, transparent and informative.
The naming convention follows this pattern:
.block{}
.block__element{}
.block--modifier{}| @media | |
| only screen and (-webkit-min-device-pixel-ratio: 1.3), | |
| only screen and (min-device-pixel-ratio: 1.3), | |
| only screen and (min-resolution: 120dpi) { | |
| /* Votre code ici pour les écrans Retina */ | |
| } |
| @module grid { | |
| $columns: 12; | |
| $gutter: 30px; | |
| $baseline: 20px; | |
| $width: 60px; | |
| @function columns($n, $size) { | |
| } | |
| function is_email(id){return (/^([\w!.%+\-\*])+@([\w\-])+(?:\.[\w\-]+)+$/).test(id);} |
##Simply annoying Tweets
Annoyingly extended words (4+ of the same letter in a phrase): OOOOHHHHMMMMYYYYGGGGOOOODDDD
([a-z])/1{4}
Tweet w/ just a single hashtag: #omgthissucks
^ *#[^ ]+$
| /* | |
| Given a date, tzAbbr returns a short, friendly name for the | |
| user's time zone on that date, or an empty string if their | |
| client's Intl support is missing or incomplete. | |
| For example, a user in New York might see: | |
| tzAbbr(new Date()) // => "EST" | |
| Time zones are locale-dependent. Users traveling outside of |
.my-module p {…})div.category {…})!important !!!If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.
In general though, avoiding the situation (nested functions and frivolous use of this) will frequently produce clearer results.
I was accidentally included in a discussion on how to best name this in nested functions in JavaScript. +1's were given to this suggestion of using _this.
Giving style advice on naming nested this without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.
| $bootstrap: false !default; | |
| $scaffold: true !default; // Output .span-n classes? | |
| $selector-type: if($scaffold, ".", "%") !default; | |
| $old-ie: false !default; | |
| $total-columns: 12 !default; | |
| $gutter: 8px !default; | |
| $container-width: 100% !default; | |
| $min-width: 240px !default; |
This gist demonstrates how to use Compass magic sprites in combination with HiDPI.
Credits: Images ©BBC News.