Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- .bash_profile실행
- .bash_profile적용안됨
- 업무시유용한git
- @at-root여러번
- multiple
- @at-root
- 카드 셔플
- 해시 #map&set
- ngrok
- leetCode #코알못의도전기 #코드알고리즘기초 #1일1알고리즘 #알고리즘공부 #코드챌린지
- zsh설치
- 코알못의도전 #알고리즘기초 #공부하는블로그
- zsh설치 후
- 유용꿀gittip
- git 팁
Archives
- Today
- Total
흑염소처럼
원하는 태그만 선택적으로 reset.scss 만들기 본문
무거운 reset.css의 나열이 아닌 필요한 태그들만 사용할 수 있다면 어떨까 ??
보통 마크업 작업을 할 때 생각보다 쓰는 태그들은 한정되어 있는데
reset.css는 필요없는 태그와 스타일들이 훨씬 많다.
scss의 placeholder와 mixin 그리고 문법을 최대한 활용하여 필요한 태그만 선택가능하게 만들어 보면 어떨까 하는 생각에서 시작되었다.
reset.scss를 원하는 스타일만 사용하도록 분기 처리하여 불필요한 스타일 제거로 응답 속도 향상에 기여하도록 만들어보자
scss Docs : https://sass-lang.com/documentation
@charset "UTF-8";
%border-style{
border: 0;
}
%box-style{
margin: 0;
padding: 0;
}
%block-style{
display: block;
}
%list-style{
list-style: none;
}
//body에 배경색이 있을 때
@mixin mw-background($color) {
@at-root #{if(&, 'body#{&}', 'body')} {
background-color: $color;
-webkit-text-size-adjust:none;
}
}
//font style 선언
@mixin font-style($size: false, $color: false, $weight: false,$style: false, $lh: false) {
font-family: 'Malgun Gothic',Helvetica,'Apple SD Gothic Neo',Dotum,sans-serif;
@if $size { font-size: $size; }
@if $color { color: $color; }
@if $weight { font-weight: $weight; }
@if $style { font-style: $style; }
@if $lh { line-height: $lh; }
}
//박스 outline 설정
@mixin reset-box-outline{
border: 0;
outline:0;
}
//폰트 리셋
@mixin reset-font {
font-size:100%;
vertical-align:baseline;
background:transparent;
}
@mixin apply_style($reset-style...){
@each $styles in $reset-style{
@extend %#{$styles};
}
}
@mixin other-reset($tag...){
@each $value in $tag {
#{$value} {
@if $value == html{
height: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
@else if $value == body{
height: 100%;
background: #f1f1f1;
-webkit-text-size-adjust:none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
@include apply_style("box-style");
@include font-style(87.5%,null,400,normal,null);
}
@else if ($value == img) or ($value == fieldset){
@include apply_style("border-style");
}
@else if ($value == li) or ($value == ol) or ($value == ul){
@include apply_style("box-style","list-style");
}
@else if $value == blockquote{
quotes:none;
}
@else if $value == a{
color:#000;text-decoration:none;text-overflow:ellipsis;
&:active,&:hover,&:link{
text-decoration:none
}
}
@else if $value == textarea{
resize: none;-webkit-appearance:none;-webkit-border-radius:0;
@include apply_style("box-style");
&:focus{
outline: 0;
}
}
@else if $value == table{
border-spacing:0;border-collapse:collapse;table-layout:fixed;
@include apply_style("box-style");
}
@else if ($value == button) or ($value == input){
appearance: none;
-webkit-border-radius: 0;
border-radius: 0;
border-width: 0;
background: 0 0;
outline: 0;
@include apply_style("box-style");
@include font-style(null,null,400,normal,null);
&:focus{
outline: 0;
}
}
@else if $value == h{
@at-root %font_style{
@include font-style(null,null,null,normal,null);
}
$list:h1,h2,h3,h4,h5,h6;
@each $tag in $list{
@at-root #{$tag}{
@extend %font_style;
@include apply_style("box-style");
}
}
}
@else if $value == article{
@include apply_style("box-style","block-style");
}
@else if $value == aside{
@include apply_style("box-style","block-style");
}
@else if $value == audio{
@include apply_style("box-style");
}
@else if $value == canvas{
@include apply_style("box-style");
}
@else if $value == detail{
@include apply_style("box-style","block-style");
}
@else if ($value == dl) or ($value == dt) or ($value == dd){
@include apply_style("box-style");
}
@else if $value == p{
@include apply_style("box-style");
}
@else if $value == fieldset {
@include apply_style("box-style");
}
@else if $value == figcaption {
@include apply_style("box-style","block-style");
}
@else if $value == footer {
@include apply_style("box-style","block-style");
}
@else if $value == header {
@include apply_style("box-style","block-style");
}
@else if $value == form {
@include apply_style("box-style");
}
@else if $value == hgroup{
@include apply_style("box-style","block-style");
}
@else if $value == legend{
@include apply_style("box-style");
}
@else if $value == menu{
@include apply_style("box-style","block-style");
}
@else if $value == figure{
@include apply_style("box-style","block-style");
}
@else if $value == nav{
@include apply_style("box-style","block-style");
}
@else if $value == section{
@include apply_style("box-style","block-style");
}
@else if $value == video{
@include apply_style("box-style","block-style");
}
@else if ($value == th) or ($value == td){
@include apply_style("box-style");
}
@else if $value == address{
@include apply_style("box-style","block-style");
}
@else if ($value == address) or ($value == caption) or ($value == cite) or ($value == code) or ($value == dfn) or ($value == em) or ($value == var) or ($value == i){
@include font-style(null,null,400,normal,null);
}
}
}
}
.blind,.skip {
overflow: hidden;
position: absolute;
clip: rect(0 0 0 0);
width: 1px;
height: 1px;
margin: -1px;
z-index: -1;
opacity: 0;
}
//필요한 해당 태그가 있다면 아래와 같이 추가합니다. 각 태그 별로 reset 스타일 노출
//원하는 리셋이 없다면 @mixin other-reset 원하는 태그 넣어서 만들어줍니다.
//h1~h6은 "h"로 통일한다.
@include other-reset("html","body","div","h","em","button","dl","dt","dd","p","img","ul","ol","li","a","caption","hr","legend","textarea","table","input","article","aside","footer","header","menu","nav","section","form","address");
'scss' 카테고리의 다른 글
@at-root 여러번 사용 (0) | 2021.01.13 |
---|---|
[SCSS Rule] 변수 선언하기 @for @function @each unquote($string) (0) | 2020.08.10 |
Scss $i 변수 @for문에 사용하기 (0) | 2020.07.15 |
Comments