HTML 이미지 패딩
html의 패딩 속성은 상자형 구조에서 가장 안쪽 요소의 콘텐츠 주위에 공간을 제공합니다. html의 margin 속성은 상자형 구조의 가장 바깥쪽 요소 내용 주위에 공간을 제공합니다. 패딩과 마진 주변의 공간을 보더라고 합니다.
아래에서 볼 수 있는 패딩, 여백, 테두리의 차이는 다음과 같습니다.
- 우리는 모든 페이지의 공통 스타일을 알고 있으므로 항상 HTML보다 CSS를 선호했습니다.
- 모든 공통 속성은 CSS로만 구현됩니다.
HTML이나 CSS에서 이미지 패딩은 어떻게 작동하나요?
- 패딩은 이미지든 콘텐츠든 항상 가장 안쪽 부분 사이에 공간을 만듭니다.
- 이미지 패딩은 CSS의 img 태그로만 정의됩니다.
구문 1:
img { Padding: 10px,10px,10px,10px; //padding positions }
구문 1 설명:
4개의 값으로 padding을 적용하면 첫 번째 값은 위쪽, 두 번째 값은 오른쪽, 세 번째 값은 아래쪽, 네 번째 값은 왼쪽에 각각 적용됩니다.
구문 2:
img { Padding: 10px,10px,10px; //padding positions }
구문 설명:
3가지 값으로 padding을 적용하면 첫 번째는 위쪽, 두 번째는 왼쪽 및 오른쪽, 세 번째는 아래쪽이 적용됩니다.
구문 3:
img { Padding: 10px,10px; //padding positions }
구문 설명:
두 개의 값으로 패딩을 적용하면 첫 번째 값은 위쪽과 아래쪽에 적용되고 두 번째 값은 왼쪽과 오른쪽에 각각 적용됩니다.
구문 4:
img { Padding: 10px; //padding positions }
구문 설명:
단일 값으로만 패딩을 적용하는 경우 네 변 모두에 동일하게 사용하세요.
HTML 이미지 패딩의 예
아래는 HTML 이미지 패딩의 예입니다.
예제 #1 – 4개의 패딩 값을 사용한 이미지 패딩
HTML 코드:
<!DOCTYPE html> <html> <head> <title>Image Padding</title> <link rel="stylesheet" href="ImagePaddingFourSides.css"></link> </head> <body> <font color="green"> <h2>Image without Padding</h2> </font> <p> <img src="Tulips.jpg" class="noPadding"> </p> <font color="green"> <h2>Image with Padding</h2> </font> <p> <img src="Tulips.jpg" class="padding"> </p> </body> </html>
CSS 코드:
.noPadding { width:400px; height:400px; border: 5px solid brown; } .padding { width:400px; height:400px; padding: 50px 50px 50px 50px; }
출력:
패딩을 적용하기 전:
패딩 적용 후:
설명:
- 위 코드에서는 첫 번째 이미지 클래스 이름인 noPadding과 두 번째 이미지 클래스 이름 패딩을 HTML 코드에서 가져왔습니다.
- CSS 코드에서 noPadding 클래스는 5px 테두리로 패딩이 없습니다. 패딩 없음은 이미지 주위에 공간을 제공하지 않습니다. 그것은 엄격하게 국경에 붙어 있습니다. 위 1첫 번째이미지 에서 확인하실 수 있습니다.
- padding 클래스에는 패딩 50px 및 50px 테두리가 있습니다. 이미지 주변의 패딩으로 인해 테두리에서 약간의 공간이 보입니다. 두 번째이미지 에서 확인하실 수 있습니다.
예제 #2 – 3개의 패딩 값을 사용한 이미지 패딩
HTML 코드:
<!DOCTYPE html> <html> <head> <title>Image Padding</title> <link rel="stylesheet" href="ImagePaddingThreeSides.css"></link> </head> <body> <font color="green"> <h2>Image without Padding</h2> </font> <p> <img src="Koala.jpg" class="noPadding"> </p> <font color="green"> <h2>Image with Padding</h2> </font> <p> <img src="Tulips.jpg" class="padding"> </p> </body> </html>
CSS 코드:
.noPadding { width:400px; height:400px; border: 5px solid yellow; } .padding { width:400px; height:400px; padding: 50px 20px 50px; border: 5px solid yellow; }
출력:
패딩을 적용하기 전:
패딩 적용 후:
설명:
- 위 코드에서는 첫 번째 이미지 클래스 이름, noPadding, 두 번째 이미지 클래스 이름 패딩을 HTML 코드에서 가져왔습니다.
- CSS 코드에서 noPadding 클래스는 5px 테두리로 패딩이 없습니다. 패딩 없음은 이미지 주위에 공간을 제공하지 않습니다. 그것은 엄격하게 국경에 붙어 있습니다. 위 1첫 번째이미지 에서 확인하실 수 있습니다.
- padding 클래스에는 50px, 20px, 50px, 5px 테두리 패딩이 있습니다. 이미지 상단 50px, 왼쪽 및 오른쪽 20px, 하단 50px 주변의 패딩으로 인해 각각. 우리는 국경에서 약간의 공간을 보았습니다. 두 번째이미지 에서 확인할 수 있습니다.
예 #3 – 3개의 패딩 값을 사용한 이미지 패딩
HTML 코드:
<!DOCTYPE html> <html> <head> <title>Image Padding</title> <link rel="stylesheet" href="ImagePaddingTwoSides.css"></link> </head> <body> <font color="green"> <h2>Image without Padding</h2> </font> <p> <img src="Desert.jpg" class="noPadding"> </p> <font color="green"> <h2>Image with Padding</h2> </font> <p> <img src="Desert.jpg" class="padding"> </p> </body> </html>
CSS 코드:
.noPadding { width:400px; height:400px; border: 5px solid yellow; } .padding { width:400px; height:400px; padding: 75px 50px; border: 5px solid yellow; }
출력:
패딩을 적용하기 전:
패딩 적용 후:
설명:
- The first image class name, noPadding, and second image class name padding have been taken in HTML code in the above code.
- In CSS code, the noPadding class has without padding with a 5px border. No padding does not give any space around the image. It strictly sticks to the border. You can see it in the above 1st image.
- The padding class has padding 75px 50px and 5px border. Due to this, padding around the image’s top and bottom is 50px, and the left and right are 50px, respectively. We have seen some space from the border. You can see it in the 2nd image.
Example #4 – Image Padding with a Single Padding Value
HTML Code:
<!DOCTYPE html> <html> <head> <title>Image Padding</title> <link rel="stylesheet" href="ImagePaddingSingleSides.css"></link> </head> <body> <font color="green"> <h2>Image without Padding</h2> </font> <p> <img src="Penguins.jpg" class="noPadding"> </p> <font color="green"> <h2>Image with Padding</h2> </font> <p> <img src="Penguins.jpg" class="padding"> </p> </body> </html>
CSS Code:
.noPadding { width:400px; height:400px; border: 5px solid blue; } .padding { width:400px; height:400px; padding: 70px; border: 5px solid blue; }
Output:
Before applying padding:
After applying padding:
Explanation:
- The first image class name, noPadding, and second image class name padding have been taken in HTML code in the above code.
- In CSS code, the noPadding class has without padding with a 5px border. No padding does not give any space around the image. It strictly sticks to the border. You can see it in the above 1st image.
- The padding class has a padding of 70 and a 5px border. Due to this, we were padding around the image top, left, right and bottom 70px around, respectively. We have seen some space from the border. You can see it in the 2nd image.
If we want to apply only particular side padding, then CSS provides predefined properties:
- Padding-left: 10px: apply padding 10px to the left side.
- Padding-right: 10px: apply padding 10px to the right side.
- Padding-top: 10px: apply padding 10px to the top side.
- Padding-bottom: 10px: apply padding 10px bottom side.
Conclusion
Image padding gives space around the innermost portion. We can apply with one, two, three, and four values with padding inside the img tag.
위 내용은 HTML 이미지 패딩의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

HTML의 테이블 테두리 안내. 여기에서는 HTML의 테이블 테두리 예제를 사용하여 테이블 테두리를 정의하는 여러 가지 방법을 논의합니다.

HTML의 Nested Table에 대한 안내입니다. 여기에서는 각 예와 함께 테이블 내에 테이블을 만드는 방법을 설명합니다.

HTML 여백-왼쪽 안내. 여기에서는 HTML margin-left에 대한 간략한 개요와 코드 구현과 함께 예제를 논의합니다.

HTML 테이블 레이아웃 안내. 여기에서는 HTML 테이블 레이아웃의 값에 대해 예제 및 출력 n 세부 사항과 함께 논의합니다.

HTML 입력 자리 표시자 안내. 여기서는 코드 및 출력과 함께 HTML 입력 자리 표시자의 예를 논의합니다.

이 튜토리얼은 PHP를 사용하여 XML 문서를 효율적으로 처리하는 방법을 보여줍니다. XML (Extensible Markup Language)은 인간의 가독성과 기계 구문 분석을 위해 설계된 다목적 텍스트 기반 마크 업 언어입니다. 일반적으로 데이터 저장 AN에 사용됩니다

HTML 순서 목록에 대한 안내입니다. 여기서는 HTML Ordered 목록 및 유형에 대한 소개와 각각의 예에 대해서도 설명합니다.

HTML onclick 버튼에 대한 안내입니다. 여기에서는 각각의 소개, 작업, 예제 및 다양한 이벤트의 onclick 이벤트에 대해 설명합니다.
