Kudos
Collect
Twiiter
Facebook
Share
Develop somethings, meditation, reading and thinking...

CSS 모든 속성을 한번에 초기화하기

마지막 업데이트 3년 전
2 0 1 0
이 글은 시리즈 ‘연재글 테스트’ 의 2 번째 포스팅입니다. 시리즈 더보기

심플하면서도 너무나 강력한 CSS 프로퍼티. 아마도 이보다 강력한 프로퍼티가 있을지 싶다.

span {
    /* all: unset !important; */
    all: unset;
}

이 프로퍼티를 유용하게 쓰은 방법 중 하나가, 아래와 같이 <button> 처럼 디폴트 디자인이 적용된 태그의 속성을 초기화 하는데 사용하는 방법이 있다.

button
Mac에서 button 태그의 디폴트 디자인

<button><a> 의 디자인을 통일하기 위해서 등, 태그의 디폴트 디자인을 없애거나 통일할 경우에 다음과 같이 편리하게 쓸 수 있다.

a, button {
    all: unset;
    font-size: 16px;
    background-color: blue;
    border: 1px solid green;
    padding: 5px;
    border-radius: 100px;
}

예전에는 이렇게 무식한 방법을 사용했었다. (자주 사용을 해서 머리를 쓴다고 LESS 의 함수로 만들어 놓고 사용. 따라하면 안됩니다.)

.css_reset() {
    animation : none;
    animation-delay : 0;
    animation-direction : normal;
    animation-duration : 0;
    animation-fill-mode : none;
    animation-iteration-count : 1;
    animation-name : none;
    animation-play-state : running;
    animation-timing-function : ease;
    backface-visibility : visible;
    background : 0;
    background-attachment : scroll;
    background-clip : border-box;
    background-color : transparent;
    background-image : none;
    background-origin : padding-box;
    background-position : 0 0;
    background-position-x : 0;
    background-position-y : 0;
    background-repeat : repeat;
    background-size : auto auto;
    border : 0;
    border-style : none;
    border-width : medium;
    border-color : inherit;
    border-bottom : 0;
    border-bottom-color : inherit;
    border-bottom-left-radius : 0;
    border-bottom-right-radius : 0;
    border-bottom-style : none;
    border-bottom-width : medium;
    border-collapse : separate;
    border-image : none;
    border-left : 0;
    border-left-color : inherit;
    border-left-style : none;
    border-left-width : medium;
    border-radius : 0;
    border-right : 0;
    border-right-color : inherit;
    border-right-style : none;
    border-right-width : medium;
    border-spacing : 0;
    border-top : 0;
    border-top-color : inherit;
    border-top-left-radius : 0;
    border-top-right-radius : 0;
    border-top-style : none;
    border-top-width : medium;
    bottom : auto;
    box-shadow : none;
    box-sizing : content-box;
    caption-side : top;
    clear : none;
    clip : auto;
    color : inherit;
    columns : auto;
    column-count : auto;
    column-fill : balance;
    column-gap : normal;
    column-rule : medium none currentColor;
    column-rule-color : currentColor;
    column-rule-style : none;
    column-rule-width : none;
    column-span : 1;
    column-width : auto;
    content : normal;
    counter-increment : none;
    counter-reset : none;
    cursor : auto;
    direction : ltr;
    display : inline;
    empty-cells : show;
    float : none;
    font : normal;
    font-family : inherit;
    font-size : medium;
    font-style : normal;
    font-variant : normal;
    font-weight : normal;
    height : auto;
    hyphens : none;
    left : auto;
    letter-spacing : normal;
    line-height : normal;
    list-style : none;
    list-style-image : none;
    list-style-position : outside;
    list-style-type : disc;
    margin : 0;
    margin-bottom : 0;
    margin-left : 0;
    margin-right : 0;
    margin-top : 0;
    max-height : none;
    max-width : none;
    min-height : 0;
    min-width : 0;
    opacity : 1;
    orphans : 0;
    outline : 0;
    outline-color : invert;
    outline-style : none;
    outline-width : medium;
    overflow : visible;
    overflow-x : visible;
    overflow-y : visible;
    padding : 0;
    padding-bottom : 0;
    padding-left : 0;
    padding-right : 0;
    padding-top : 0;
    page-break-after : auto;
    page-break-before : auto;
    page-break-inside : auto;
    perspective : none;
    perspective-origin : 50% 50%;
    position : static;
    /* May need to alter quotes for different locales (e.g fr) */
    quotes : '201C' '201D' '2018' '2019';
    right : auto;
    tab-size : 8;
    table-layout : auto;
    text-align : inherit;
    text-align-last : auto;
    text-decoration : none;
    text-decoration-color : inherit;
    text-decoration-line : none;
    text-decoration-style : solid;
    text-indent : 0;
    text-shadow : none;
    text-transform : none;
    top : auto;
    transform : none;
    transform-style : flat;
    transition : none;
    transition-delay : 0s;
    transition-duration : 0s;
    transition-property : none;
    transition-timing-function : ease;
    unicode-bidi : normal;
    vertical-align : baseline;
    visibility : visible;
    white-space : normal;
    widows : 0;
    width : auto;
    word-spacing : normal;
    z-index : auto;
}

무식하면 용감하다는걸 너무나도 잘 보여준다….😅

참조

https://developer.mozilla.org/en-US/docs/Web/CSS/all

Hi, my name is Richard. I’m a developer wants to make the world better with logic power. Mainly I use Linux, Nginx, MySQL, PHP and JavaScript . I want to share my knowledge with someone that it was also based from some great persons via LYNMP. 👨‍💻

연재
연재 글 테스트 설명 내용
Essedrop - 이미지 주소를 만드는 가장 빠른 방법
 

독자 의견

저자 @richard 에게 의견 남기기:

Please sign in to comment.
Markdown is also available in comment.