본문 바로가기

HTML

[CSS] clip: rect()를 사용한 사진 자르기

<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scable=no">

    <title>index</title>

    <style>
        .c {
            position: absolute;
            clip: rect(10px, 250px, 250px, 150px); /* top, right, bottom, left */
        }

        img {
            border: 5px solid red;
        }
    </style>
</head>

<body>
    <h2>원본 사진 (273x185)</h2>
    <img src="images/img.jpg">

    <h2>clip: rect(10px, 250px, 250px, 150px);</h2>
    <p>clip: rect(top, right, bottom, left);</p>
    <img src="images/img.jpg" class="c">
</body>
</html>

'HTML' 카테고리의 다른 글

[CSS] z-index  (0) 2020.08.14
[CSS] transform: rotate()를 사용한 사각형 회전  (0) 2020.08.14
[CSS] text-overflow, line-height  (0) 2020.08.14
[CSS] after, before  (0) 2020.08.14
[CSS] Flexible Box (플렉서블 박스)  (0) 2020.08.14