본문 바로가기

HTML & CSS

여러개로 구성된 하나의 이미지 중 원하는 영역 배경이미지 사용(spritecow 이미지 좌표 확인 사이트)

*참고 사이트

http://www.spritecow.com/

 

Sprite Cow - Generate CSS for sprite sheets

Sorry, it isn't working out between us It's not you, I just can't get along with your browser. Maybe if things change in the future... maybe if you bring Chrome, Firefox, Opera or even IE10 to the party... not promising anything, but give me a call.

www.spritecow.com

 

*이용 방법

-사이트에 들어가 'open image'를 누른다.

-해당 영역을 클릭하면 아래에 좌표가 뜨는 것을 복사하고 css에 붙여넣는다.

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div.sprite{
        background: url('img/sprite.png') no-repeat 0 -304px;
        width: 218px;
        height: 72px;
        }
    </style>
</head>
<body>
    <div class="sprite"></div>
</body>
</html>

 

* 배경이미지 크기 조절하고 싶을때 (background, background-size, width, height 재설정)

 

footer .seller-service-btn::after{
    content:''; display: block;
    background: url('../img/sprite__common.png') no-repeat -343.5px -117.5px;
    /* background,width,height는 http://www.spritecow.com/에 이미지파일올리고 위치좌표구한것 */
    background-size: 400px auto;/*이미지사이즈800절반(속성보고 따로 추가) 400하고 
    위에 background위치랑 width,height반으로 나눔*/
	width: 9.5px;
	height: 5px;
    position: absolute;
    right: 8px; top:50%; transform: translateY(-50%);
    }