przez Piotr Delikat 10 lat temu
1498
Więcej takich
Subtopic
zabrania wyszukiwarka zapisywać strony na kompie użytkownika
wartość metatagu
robots
nofollow
mają nie indeksować jedynie łączy umieszczonych na stronie
noindex
mają nie indeksować strony w wyszukiwarkach
można wygonić roboty wyszukujace od strony
keywords
bez wpływu na pozycje w wyszukiwarce
oddzielone przecinkami
description
można potem dowolnie przerobić fragment tekstu w CSS
jak div grupuje elementy, ale w jednym wierszu, a nie w całym bloku
frameborder
seamless
blokuje wyświetlanie pasków przewijania
np. ramka z google maps
gdy poraz pierwszy wyjaśniamy znaczenie jakiegoś pojęcia
atrybut title="..."
pozwala podać znaczenie sktótu
odwołanie się do książki filmu etc.
udostępniają atrybut cite="..."
dla podania linka do źródła cytatu
dłuższe cytaty jako osobne paragrafy
krótsze cytaty wewnątrz tekstu
domyślnie- kursywa, większy nacisk na znaczenie fragmentu
pogrubienie tekstu, większy nacisk na fragmet tekstu
CO<sub>2</sub>
E = mc<sup>2</sup>
walidacja formularzy
by wyłączyć
grupowanie formularzy
for="IdFormularza"
etykiety do formularzy
obszerny obszar do wpisania textu
action="..."
link do strony wysyłjącej lub odbierającej informacje
method='get' // 'post' // inna metoda
placeholder="wartośćZnikaPoKilknięciu"
do umożliwienia zaznaczenia kilku opcji
selected=”selected”
do wyboru domyślnej opcji
checkbox
wiele opcji możliwych
type="checkbox"
radio buttons
checked="checked"
domyśłnie zaznaczony
value="nazwaButtona"
tylko jedna z opcji możliwa
type="radio"
id="dlaLabel"
name="identyfikacjaDlaSerwera"
maxlenght=23;
określa max liczbę znaków jakie można wpisać
type="text" // "password" // "email" // file // submit // image // hidden // date // url // search
footer tabeli
łacznenie komórek dwóch rzędów w kolumnie
łączenie komórek dwóch kolumn w jednym rzędzie
komórka
body tabeli
nagłówek do rzędów
wiersz
nagłówek tablei
nowy element HTML5, pozwala na powiązanie obrazu z opisem
tak samo można kierować do okteślonych miejsc na innych stronach
zamiast przewijania
względne w stosunku do bazowego index.html
../../subsite.html
nadrzędny x2 katalog
../subsite.html
nadrzędny katalog
termin
definicja
lista
lista
element listy
domyślnie z kropkami, kolejność mniej ważna
domyślnie z kropkami, kolejność mniej ważna
domyślnie z kropkami, kolejność mniej ważna
CSS list-style-type: ...;
domyślnie z numerami, istotna kolejność
CSS list-style-type: ...;
domyślnie z numerami, istotna kolejność
CSS list-style-type: ...;
domyślnie z numerami, istotna kolejność
collapsing height
setting a ClearFix
pro solution
give a parent element the .group
.group:after{content: ""; display: table; clear: both; }
clear: both;
clears both site of a collapsing space
overflow
not recomendet solution
:auto;
tell the browser to account the height of a floats
sets elements to initial scale of device
good for mobile media queries
.warper,
.nav li {
width: initial;
height: initial;
float: initial;
}
like a block element, but in a flow of it's surroundings
sets elements in the flow of content
default for anchor elements
block element takes all available space of a parent element
default option of displaying
turn of displaying of an element
// Screen reader text
.srt {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
for clearnig list decotarion
line-height : ($base__line/$base__font_size);
:focus
when you interact with keyboard for ex.(by tab)
implies that user is redy for interaction
:active
not only for links or buttons
most common in nav section
:hover
:visited
:link
not visited links
good for icons and small graphic elements
content: "blank/text"; / content: url(.../img.svg);
content is obligatory
gives us extra layers to work with :)
they are visible to user, but do not appear in the HTML source code
sets the virtual element befor or after selected element
most specific
less sepcific
header span {
color : white;
font-size : 26px;
}
only nestedElement will be changed
by default list are indented left
padding-left: 0;
by default list style is outsite the
list-style-position
list-style-position
:inside;
to change it
:none;
:decimal-leading-zero;
:square/circle/decimal/lover-latin/etc..;
rounded corners of the element
: %;
50% is a circle
border-top : 2px solid blue;
background-image: #45690 url('path/image.jpg') no-repeat center / cover;
:x y;
:20% 50%;
:right bottom;
:center center;
= :center;
left top corner by default
:no-reapeat;
:repeat-y;
only on y axis
:repeat-x;
only on x axis
it's :repeat; by default
relative to the element size
:cover;
best for full background images
fits the image proportionally to the full size of element
:
it is repaeted horizontaly/verticaly by default
: url('path/image.jpg');
it is good practice to set the contrast to content color. Even with bg-img in case of problems with displaying it
it can be universal for whole project
* {
box-sizing: border-box;
}
calculate width and height substracting box model values
helps us with calculation of size of elements
img {max-width: 100%;}
px are for precise elements like graphics/icons
with % element is relative to the parent element
states at mobile
collapse at mobile class
is displayed at mobile class
_grid_display
==========================================================================
// Grid display
// ==========================================================================
.is-displayed-mobile {
@include mq(small) {
display: block;
@at-root (with: media) {
.is-hidden-mobile {
display: none;
}
}
}
@include mq(medium) {
display: none;
}
}
mixin
// Media queries
@mixin mq($break) {
@if $break == "small" {
@media (min-width: $brkpoint-sm) and (max-width: $brkpoint-md) {
@content;
}
}
@else if $break == "medium" {
@media (min-width: $brkpoint-md + 1) {
@content;
}
}
@else if $break == "large" {
@media (min-width: $brkpoint-lg) {
@content;
}
}
@else {
@error "Whoops! No value could be retrieved for '#{$break}'."
}
}
variables fro breakpoints
_config.scss
// Breakpoints
$brkpoint-sm : 1px;
$brkpoint-md : 768px;
$brkpoint-lg : 1100px;
usage
class="grid__col--12"
full width in the grid
class="grid"
center the content
we also need to specify a container for grid
_grid-container.scss
.grid {
@extend %clearfix;
@extend .centered;
width: 90%;
// Make nested grid container 100%
[class*="grid__col--"] > & {
width: 100%;
}
// Set a max-width grid container
@media(min-width: 1100px) {
max-width: $g-cout-max-w;
}
}
mixin to adjust column siblings
// Adjacent sibling margins
@mixin doubly($margin: 1em) {
& + & {
margin-left: $margin;
@content;
}
}
loop to generate calsses
_grid-columns.scss
// Calculate grid columns
@media (min-width: 769px) {
@for $i from 1 through $g-col-count {
$context: g-context($g-col-width, $g-col-count, $g-gutter-width) !global;
$target: ($g-col-width * $i) + ($g-gutter-width * ($i - 1));
//Generate column modifier classes
.grid__col--#{$i} {
width: percentage($target / $context);
}
}
}
// Column Styles
[class^="grid__col--"] {
@media (min-width: 1px) and (max-width: 768px) {
margin-top: em(12px);
margin-bottom: em(12px);
}
@media (min-width: 769px) {
@include doubly(percentage($g-gutter-width / $context));
float: left;
min-height: 1px;
padding-left: 10px;
padding-right: 10px;
&:last-of-type {
float: right;
}
}
}
output
.grid__col--1 {
width: 6.5%; }
.grid__col--2 {
width: 15%; }
.grid__col--3 {
width: 23.5%; }
.grid__col--4 {
width: 32%; }
.grid__col--5 {
width: 40.5%; }
.grid__col--6 {
width: 49%; }
.grid__col--7 {
width: 57.5%; }
.grid__col--8 {
width: 66%; }
.grid__col--9 {
width: 74.5%; }
.grid__col--10 {
width: 83%; }
.grid__col--11 {
width: 91.5%; }
.grid__col--12 {
width: 100%; }
@function to count context
_functions.scss
// Set the "context" width for the grid
@function g-context($g-col-width, $g-col-count, $g-gutter-width) {
$g-context : ($g-col-width * $g-col-count) + ($g-gutter-width * ($g-col-count - 1));
@return $g-context;
}
nessesery variables
_config.scss
// Grid
$g-col-width : 65px;
$g-gutter-width : 20px;
$g-col-cound : 12;
$g-cont-max-w : 1050px;
Scalable and Modular Architecture for CSS
sassy - SMACSS based starter for a project
application.scss
@imports
order of imported parts is important!
categoryName/_index.scss
which contain all the partial files
from the folders of categories
divdes project into categories
optionaly
utilities
_helpers
_functions
_mixins
themes
default category
like for wordpress themes
diffrent colors and images for diffrent color themes
states
style for element states
:hidden, :active, :expand etc.
modules
each module as a separate, reusable component
majority of project styles
layout
major sections of the page
panel rules for positioning header and footer
.panel {
@extend %panel-default;
@include m(centered) {
@extend %panel-default;
@extend %center-align;
}
@include m(padded) {
@extend %panel-padding;
@include m(centered) {
@extend %center-align;
@extend %panel-padding;
}
}
}
@extends
// Panels
%panel-default {
padding-top: em(30px);
padding-bottom: em(20px);
}
%panel-padding {
padding-top: em(80px);
padding-bottom: em(34px);
}
// Center alignment
%center-align {
text-align: center;
}
some developers avoid this category
header, footer, sidebar, grid
wrappers for other componenets
base
use only element selectors
no classes and id-s
give them default values
reset styles
how the elements looks by default
to organize and structure CSS on any scale
more like a architecture style guid
Block Element Modifier
Sass way
form
.form {
@include e(label) {
@include m(hidden) {
@extend .srt;
}
dispaly: block;
margin-bottom: em(10px);
}
@include e(input) {
width: 100%;
font-size: em(18px);
padding: em(15px, 18px);
margin-bottom: em(20px, 18px);
border-bottom: 6px solid palette(grey, x-light);
border-radius: $br--default;
background: palette(grey, xx-light);
color: palette(black, dark);
font-weight: $font-weight--light;
&:focus {
border-color: $color-primaty;
}
}
@include e(btn) {
@extend %btn;
background-color: $color-primary;
}
}
classes
.form
.form__lable
.form__label--hidden //for screan readers
.form__input // :active
.form__btn //for submit button
headline
.headline {
&-primary {
@extend %hdln-prim;
margin-bottom: em(70px, 42px);
}
&-secondary {
@extend %hdln-sec;
margin-bottom: em(22px, 24px);
}
}
@extension
// Headlines
%hdln-prim {
font-weight: $font-weight--light;
font-size: em(42px);
line-height: (46px / 42px);
margin-bottom: em(70px, 42px);
color: palette(grey, x-dark);
margin-top: 0;
}
%hdln-sec {
font-family: $font-family--secondary;
font-weight: $font-weight--thin;
font-size: em(24px);
color: palette(grey, light);
letter-spacing: $letter-space;
}
navigation
ex
.nav {
margin-top: em(20px);
margin-bottom: em(30px);
&__item {
display: inline-block;
margin: 0 em(12px);
a {
font-size: em(18px);
font-weight: $font-weight--light;
color: palette(grey);
display: block;
padding: em(8px, 18px);
}
&--current a {
color: palette(black);
border-color: $color-primary;
}
}
}
output 4 classes
.nav
.nav__item
.nav__item a //active only on anchor elements
.nav__item--current a //active only on selected anchor element
with @extend
_extend.scss
// Nav Items
%nav-item-disp {
display: inline-block;
margin: 0 em(12px);
}
%nav-item-link {
font-size: em(18px);
font-weight: $font-weight--light;
display: block;
padding: em(8px, 18px);
border-bottom: 1px solid transparent;
}
%nav-item-on {
color: palette(black);
border-color: $color-primary;
}
.nav {
margin-top: em(20px);
margin-bottom: em(30px);
@include e(item) {
@extend %nav-item-disp;
a {
@extend %nav-item-link;
color: palette(grey);
&:hover {
@extend %nav-item-on;
}
}
@include m(current) {
@extend %nav-item-disp;
a {
@extend %nav-item-link;
@extend %nav-item-on;
}
}
}
}
BEM @mixin
@mixin e($element) {
&__#{$element} {
@content;
}
}
@mixin m($modifier) {
&--#{$modifier} {
@content;
}
}
Modifier = Styles and Variations
Element = child of the root element
Block = root of the element
highest level of abstraction
.block__element--modifier
.list__item--block {}
.list__item {}
.list {}
naming convention based on class
downsite of BEM approach is lots of classes in html
but
readability is more important
of course not everything can be taken under this nameing convention
ex .site-logo
help us to write clear and easy to understand CSS
body {
font-size : $base__font-size;
line-height : ($base__line/$base__font_size)
font-family : $font-family--primary;
}
map-get(map-get($mapName, value) nestedValue);
pallets of colors
grey & black
$palettes: (
grey: (
xx-light : lighten($grey, 43%),
x-light : lighten($grey, 35%),
light : lighten($grey, 12%),
base : $grey,
dark : darken($grey, 8%),
x-dark : darken($grey, 16%)
),
black: (
light : lighten($black, 10%),
base : $black,
dark : darken($black, 10%),
)
);
how to get it
of write a function :)
@function palette($pallete, $shade: 'base') { @return map-get(map-get($palettes, $pallete), $shade); }
call it with
color: palette(grey, x-dark);
color : map-get(map-get($palettes, grey) x-grey);
we need @mixin to genetare classes
@each $theme, $color in $ui-colors {
.btn--#{$theme} {
background-color : $color;
}
}
even more modular
@mixin bg-colors($map) { @each $theme, $color in $map { &--#{$theme} { background-color : $color; } } }
we can make class first in css, and use it in HTML later
$ui-colors: (
default : $fountain-blue,
success : $emerald,
error : $sunglo,
warning : $coral,
info : $purple-majesty
);
@error
ex.
@else {
@error "'{$pos}' is an invalid argument.";
}
shows error in css output (and browser)
@warn
shows warrning in the console
// Call the color palette modifiers
@function palette($pallete, $shade: 'base') {
@return map-get(map-get($palettes, $pallete), $shade);
}
//Calculate pixels to em values
@function em($target, $context: $base__font_size) {
@return ($target / $context) * 1em;
}
font-size : em(42px);
usage for H1
h1 {
font-size : em(42px);
line-height : (46px / 42px);
margin-bottom : em(70px, 42px);
}
//Import if Google Fonts URL is defined
@if variable-exists(font-url--google) {
@import url($font-url--google);
}
@extend .ruleName;
@extend %extensionName;
you can include %extends and rules from other files onto every element
really helpful to make Sass DRY
file name for functions and mixins
generating pseudo elements shapes with @error
@mixin p-el(
$el,
$el-w: null,
$el-h: null) {
@if $el == "before" or $el == "after" {
&:#{$el} {
@extend %pseudos;
width: $el-w;
height: $el-h;
@content;
}
} @else {
@error "'#{$el}' is not a valid pseudo-element.";
}
}
@content //for pseudo elements
%pseudos {
display: block;
content: '';
position: absolute;
}
background-image
@mixin img-replace($img, $w, $h, $disp: block ) {
background-image: url('#{$path--rel}/#{$img}');
background-repeat: no-repeat;
width: $w;
height: $h;
display: $disp;
}
ex. usage
@include img-replace('logo.svg', 115px, 45px, inline-block);
like a loops
@each $parOne, $parTwo in $mapName {.class-- #{$parOne} { cssKey : $parTwo; }}
to create classes for ex.
//Color maps
@each $theme, $color in $ui-colors {
.btn--#{$theme} {
background-color : $color;
}
}
like a functions
//path to images
$path--rel : "../img";
//letter-space
$letter-space : 1px;
//font size
$base__line : 24px;
$base__font-size : 16px;
//color usage
$color-shadow : rgba($black, .2);
$color-accent : $purple-majesty;
$color-primary : $black;
//descriptive Base Colors
$grey : #797e83;
$black : #0b0b0b;
more fancy black :)
$white : #fff;
//font weight
$font-weight--thin
etc.
$font-weight--thin : 100;
$font-weight--light : 300;
$font-weight--medium : 400;
$font-weight--bold : 700;
$font-weight--ultra-bold : 900;
//font stack
of some more clever fontstack
$font-family--primary
$font-family--primary : 'Lato', 'Helvetica Neue','Helvetica','Arial', 'sans-serif';
//font url
$font-url--google
$font-url--google : 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900';
BEM nameing convention
good practice
good name for variables file