05. HTML/css

10. CSS - SVG 를 Background-Img 로 사용하기

THE HEYDAZE 2021. 9. 13. 12:56

 

아이콘 SVG 검색
 

Material Design Icons

Material Design Icons' growing icon collection allows designers and developers targeting various platforms to download icons in the format, color and size they need for any project. Loading... Sponsored by Icons8 Material Icon Sets

materialdesignicons.com

원하는 아이콘을 선택하여 SVG 를 복사 (빨간색 테두리 아이콘은 유료입니다)

 

배경이미지로 변환
 

URL-encoder for SVG

 

yoksel.github.io

background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='width:24px;height:24px' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M19,19H5V5H15V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V11H19M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z' /%3E%3C/svg%3E");

 

 

화면

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .check-icon {
            width: 24px;
            height: 24px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='width:24px;height:24px' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M19,19H5V5H15V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V11H19M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z' /%3E%3C/svg%3E");
        }
    </style>
</head>
<body>

<div class="check-icon"></div>

</body>
</html>

 

 

<select> 활용 예시