-
-
Save scottdorman/6b4564565a9a110fdb7f to your computer and use it in GitHub Desktop.
codestyle.co examples
This file contains hidden or 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
codestyle.co examples |
This file contains hidden or 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
/* Bad example */ | |
.t { ... } | |
.red { ... } | |
.header { ... } | |
/* Good example */ | |
.tweet { ... } | |
.important { ... } | |
.tweet-header { ... } |
This file contains hidden or 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
.declaration-order { | |
/* Positioning */ | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
z-index: 100; | |
/* Box-model */ | |
display: block; | |
float: right; | |
width: 100px; | |
height: 100px; | |
/* Typography */ | |
font: normal 13px "Helvetica Neue", sans-serif; | |
line-height: 1.5; | |
color: #333; | |
text-align: center; | |
/* Visual */ | |
background-color: #f5f5f5; | |
border: 1px solid #e5e5e5; | |
border-radius: 3px; | |
/* Misc */ | |
opacity: 1; | |
} |
This file contains hidden or 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
<!-- Use link elements --> | |
<link rel="stylesheet" href="core.css"> | |
<!-- Avoid @imports --> | |
<style> | |
@import url("more.css"); | |
</style> |
This file contains hidden or 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
.element { ... } | |
.element-avatar { ... } | |
.element-selected { ... } | |
@media (min-width: 480px) { | |
.element { ...} | |
.element-avatar { ... } | |
.element-selected { ... } | |
} |
This file contains hidden or 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
// Without nesting | |
.table > thead > tr > th { … } | |
.table > thead > tr > td { … } | |
// With nesting | |
.table > thead > tr { | |
> th { … } | |
> td { … } | |
} |
This file contains hidden or 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
* | |
* Component section heading | |
*/ | |
.element { ... } | |
/* | |
* Component section heading | |
* | |
* Sometimes you need to include optional context for the entire component. Do that up here if it's important enough. | |
*/ | |
.element { ... } | |
/* Contextual sub-component or modifer */ | |
.element-heading { ... } |
This file contains hidden or 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
/* Prefixed properties */ | |
.selector { | |
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); | |
box-shadow: 0 1px 2px rgba(0,0,0,.15); | |
} |
This file contains hidden or 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
/* Bad example */ | |
span { ... } | |
.page-container #stream .stream-item .tweet .tweet-header .username { ... } | |
.avatar { ... } | |
/* Good example */ | |
.avatar { ... } | |
.tweet-header .username { ... } | |
.tweet .avatar { ... } |
This file contains hidden or 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
/* Bad example */ | |
.element { | |
margin: 0 0 10px; | |
background: red; | |
background: url("image.jpg"); | |
border-radius: 3px 3px 0 0; | |
} | |
/* Good example */ | |
.element { | |
margin-bottom: 10px; | |
background-color: red; | |
background-image: url("image.jpg"); | |
border-top-left-radius: 3px; | |
border-top-right-radius: 3px; | |
} |
This file contains hidden or 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
/* Single declarations on one line */ | |
.span1 { width: 60px; } | |
.span2 { width: 140px; } | |
.span3 { width: 220px; } | |
/* Multiple declarations, one per line */ | |
.sprite { | |
display: inline-block; | |
width: 16px; | |
height: 15px; | |
background-image: url(../img/sprite.png); | |
} | |
.icon { background-position: 0 0; } | |
.icon-home { background-position: 0 -20px; } | |
.icon-account { background-position: 0 -40px; } |
This file contains hidden or 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
/* Bad CSS */ | |
.selector, .selector-secondary, .selector[type=text] { | |
padding:15px; | |
margin:0px 0px 15px; | |
background-color:rgba(0, 0, 0, 0.5); | |
box-shadow:0px 1px 2px #CCC,inset 0 1px 0 #FFFFFF | |
} | |
/* Good CSS */ | |
.selector, | |
.selector-secondary, | |
.selector[type="text"] { | |
padding: 15px; | |
margin-bottom: 15px; | |
background-color: rgba(0,0,0,.5); | |
box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff; | |
} |
This file contains hidden or 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
<a class="..." id="..." data-modal="toggle" href="#"> | |
Example link | |
</a> | |
<input class="form-control" type="text"> | |
<img src="..." alt="..."> |
This file contains hidden or 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
<input type="text" disabled> | |
<input type="checkbox" value="1" checked> | |
<select> | |
<option value="1" selected>1</option> | |
</select> |
This file contains hidden or 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
<head> | |
<meta charset="UTF-8"> | |
</head> |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
</html> |
This file contains hidden or 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
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> |
This file contains hidden or 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
<!-- External CSS --> | |
<link rel="stylesheet" href="code-guide.css"> | |
<!-- In-document CSS --> | |
<style> | |
/* ... */ | |
</style> | |
<!-- JavaScript --> | |
<script src="code-guide.js"></script> |
This file contains hidden or 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
<html lang="en-us"> | |
<!-- ... --> | |
</html> |
This file contains hidden or 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
<!-- Not so great --> | |
<span class="avatar"> | |
<img src="..."> | |
</span> | |
<!-- Better --> | |
<img class="avatar" src="..."> |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page title</title> | |
</head> | |
<body> | |
<img src="images/company-logo.png" alt="Company"> | |
<h1 class="hello-world">Hello, world!</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment