On Github hbuchel / dnncss
Build tools can help streamline development, making it easier to maintain projects.
Using OOCSS principles, our CSS will be easier to scale, modify, and grow.
Revisiting older projects will be less of a pain when it comes time for new additions.
Your front-end devs will delight in cleaner stylesheets and having less pain points!
News - Events - Content Types
News - Content Types
Everything ever!
h2 { color: #111; border-bottom: 1px solid #eee; padding: 10px 0; }
.callout-title { color: #111; border-bottom: 1px solid #eee; padding: 10px 0; }
.nav li { display: inline-block } .nav li a { display: block; padding: 10px; }
.nav__item { display: inline-block; } .nav__link { display: block; padding: 10px; }
<div class="sidebar"> <a class="button">Button</a> </div> .button { display: block; padding: 10px; background: white; color: black } .sidebar .button { background: black; color: white; }
<div class="sidebar"> <a class="button button--alt">Button</a> </div> .button { display: block; padding: 10px; background: white; color: black } .button--alt { background: black; color: white; }
.featured-article { padding: 20px; flex: 2; background: lightgray; border: 1px solid darkgray; }
.column, .featured-article { padding: 20px; flex: 2; } .box, .featured-article { background: lightgray; border: 1px solid darkgray; }
.column, %column { padding: 20px; flex: 2; } .box, %box { background: lightgray; border: 1px solid darkgray; } .featured-article { @extend %column; @extend %box; }
.button-primary { background: #4AADB7; border: 1px solid #3E919A; display: inline-block; line-height: 1; color: #fff; text-decoration: none; background: none; text-align: center; font-weight: 700; padding: 10px; border: none; border-radius: 5px; font-size: 1.3rem; } .button-primary:hover, .button-primary:focus { background: #3E919A; color: #fff; }
.button-secondary { background: #93A1A7; border: 1px solid #727D82; display: inline-block; line-height: 1; color: #fff; text-decoration: none; background: none; text-align: center; font-weight: 700; padding: 10px; border: none; border-radius: 5px; font-size: 1.3rem; } .button-secondary:hover, .button-secondary:focus { background: #727D82; color: #fff; }
/* button */ .button, .button-primary, .button-secondary { display: inline-block; line-height: 1; text-decoration: none; background: none; text-align: center; font-weight: 700; padding: 10px; border: 1px solid transparent; border-radius: 5px; font-size: 1.3rem; } /* button-primary */ .button-primary { background: #4AADB7; border-color: #3E919A; color: #fff; } .button-primary:hover, .button-primary:focus { background: #3E919A; color: #fff; } /* button-secondary */ .button-secondary { background: #93A1A7; border-color: #727D82; color: #fff; } .button-secondary:hover, .button-secondary:focus { background: #727D82; color: #fff; }
/* button */ .button, %button { display: inline-block; line-height: 1; text-decoration: none; background: none; text-align: center; font-weight: 700; padding: 10px; border: 1px solid transparent; border-radius: 5px; font-size: 1.3rem; } /* button-primary */ .button-primary { @extend %button; background: #4AADB7; border-color: #3E919A; color: #fff; &:hover, &:focus { background: #3E919A; color: #fff; } } /* button-secondary */ .button-secondary { @extend %button; background: #93A1A7; border-color: #727D82; color: #fff; &:hover, &:focus { background: #727D82; color: #fff; } }
.u-block-text, %u-block-text { line-height: 1; text-decoration: none; padding: 10px; display: inline-block; } /* button */ .button, %button { @extend %u-block-text; text-align: center; background: none; font-weight: 700; border: 1px solid transparent; border-radius: 5px; font-size: 1.3rem; } /* button-primary */ .button-primary { @extend %button; background: #4AADB7; border-color: #3E919A; color: #fff; &:hover, &:focus { background: #3E919A; color: #fff; } } /* button-secondary */ .button-secondary { @extend %button; background: #93A1A7; border-color: #727D82; color: #fff; &:hover, &:focus { background: #727D82; color: #fff; } }
/* buttons */ // .. previous button modules .button--block { display: block; width: 100%; } .button--disabled { background: #eee; color: #aaa; &:hover { cursor: no-drop; } &:hover, &:focus { background: #eee; color: #aaa; } } .button--active { &:before { content: ''; @extend .icon-check; vertical-align: middle; margin: 0 5px; } }
<button class="button-primary button--block">Block</button> <button class="button-primary button--disabled">Disabled</button> <button class="button-primary button--active">Active</button>
<div class="flex"> <div class="flex__image"> <img src="image.jpg" alt=""> </div> <div class="flex__content"> <h2 class="flex__title"> <a href="#">Title Text</a> </h2> <p>Paragraph Text</p> </div> </div>
<div class="flex-list"> @foreach(var e in List) { var Content = e.Content; <div class="flex"> <div class="flex__image"> <img src="@Content.flex_image" alt="@Content.flex_image_alt"> </div> <div class="flex__content"> <h2 class="flex__title"> <a href="@Content.flex_link">@Content.flex_title</a> </h2> @Html.Raw(@Content.flex_content) </div> </div> } </div>
.flex { display: flex; flex-direction: column; margin-bottom: 20px; } .flex__image { img { width: 100%; } }
.flex-list { display: flex; flex-direction: column; margin: 0 -20px; @include breakpoint($tablet) { flex-direction: row; } .flex { flex: 1; padding: 0 20px; } }
<div class="flex flex--row"> <!-- rest of .flex code --> </div>
.flex--row { @include breakpoint($mobile) { flex-direction: row; .flex__content { padding-left: 20px; } .flex__image { max-width: 45%; } } }
<div class="flex-list flex-list--bullets"> <div class="flex flex--row"> <!-- rest of .flex code --> </div> </div>
.flex-list--bullets { @include breakpoint($tablet) { flex-wrap: wrap; .flex { flex: 1 0 (100%/3); } } }
.flex { display: flex; flex-direction: column; margin-bottom: 20px; } .flex__image { img { width: 100%; } } .flex--row { @include breakpoint($mobile) { flex-direction: row; .flex__content { padding-left: 20px; } .flex__image { max-width: 45%; } } } .flex-list { display: flex; flex-direction: column; @include breakpoint($tablet) { flex-direction: row; } margin: 0 -20px; .flex { flex: 1; padding: 0 20px; } } .flex-list--bullets { @include breakpoint($tablet) { flex-wrap: wrap; .flex { flex: 1 0 (100%/3); } } }
/* Variables */ $blue: #4778c6; $gray: #eee; $radius: 14px; p { color: $blue; background: $gray; border-radius: $radius; }
p { color: #4778c6; background: #eee; border-radius: 14px; }
.box-sizing, %box-sizing { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .callout, %callout { font-size: 24px; line-height: 1.6; } .column { padding: 10px; background: $blue; @extend %box-sizing; @extend %callout; }
.box-sizing, .column { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .callout, .column { font-size: 24px; line-height: 1.6; } .column { padding: 10px; background: #4778c6; }
@mixin image-replace { display: block; text-indent: 100%; overflow: hidden; white-space: nowrap; } .button { background: url(button.bg); @include image-replace; }
.button { background: url(button.bg); display: block; text-indent: 100%; overflow: hidden; white-space: nowrap; }
@mixin font-size($sizeValue: 1){ font-size: ($sizeValue) + px; font-size: ($sizeValue / 10) + rem; } html { font-size: 62.5%; } body { @include font-size(16); }
body { font-size: 16px; font-size: 1.6rem; }
@mixin breakpoint($break) { @media (min-width: $break) { @content; } } @include breakpoint($tablet) { .footer-connect { width: span(4); } }
@media (min-width: 920px) { .footer-connect { width: 40%; } }
Codepen
Github