Skip to content

Instantly share code, notes, and snippets.

@rejgan318
Last active May 4, 2023 10:27
Show Gist options
  • Save rejgan318/26b90f1289f53bbe0228c00f52cdf1db to your computer and use it in GitHub Desktop.
Save rejgan318/26b90f1289f53bbe0228c00f52cdf1db to your computer and use it in GitHub Desktop.
[web] css

CSS, SCSS

  • nullstyle.scss обнуляющий стиль, сброс
  • scss.md - основные возможности
/*Обнуление*/
*{padding: 0;margin: 0;border: 0;}
*,*:before,*:after{-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}
:focus,:active{outline: none;}
a:focus,a:active{outline: none;}
nav,footer,header,aside{display: block;}
html,body{height:100%;width:100%;font-size:100%;line-height:1;font-size:14px;-ms-text-size-adjust:100%;-moz-text-size-adjust:100%;-webkit-text-size-adjust:100%;}
input,button,textarea{font-family:inherit;}
input::-ms-clear{display: none;}
button{cursor: pointer;}
button::-moz-focus-inner{padding:0;border:0;}
a,a:visited{text-decoration: none;}
a:hover{text-decoration: none;}
ul li{list-style: none;}
img{vertical-align: top;}
h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight: inherit;}
/*--------------------*/

SCSS - основные возможности

Вложенность

.block {
  font-size: 3em;
  line-height: 140%;
  color: red;
  p {       // .block p
    color: green;
  }
}

& Подстановка имени родительского класса

.block {
  font-size: 3em;
  &-nav {  // .block .block-nav
    color: red;
  }
  &:hover { color: red; }   // .block:hover
}

Переменные

$fz:80px;

.block {
  font-size: $fz; 
}

Импорт других файлов стилей

@import "nullstyle.scss";

Шаблоны

%tpl-border {
  border-bottom: 5px dashed red;
}
.link1 {
  color: red;
  @extend %tpl-border
}

Миксины

@mixin fontz($size) {
  font-size: $size;
}
.link1 {
  @include fontz(100px);
  color: red;
}

Выражения

width: 300px / 960px * 100%; // -> width: 31.25%;

Комментарии

// такой комментарий не попадет в результирующий css
/* а такой попадет */

If, for и пр...

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment