최근에 프로젝트 작업 중에 페이지에 대한 계층 적 프레임 워크를 그리기 위해 iframe을 자주 사용해야합니다. 대부분의 브라우저에는 배경이 없지만 IFRAME에는 기본적으로 흰색 배경색이 있습니다. 기본 배경색이 흰색이 아닌 경우이 부분에서 갑자기 나타납니다. 솔루션은 도움말 매뉴얼에 제공됩니다. 해당 예제는 다음과 같이 도움말 문서에도 제공됩니다.
코드를 복사하십시오
코드는 다음과 같습니다.
<바디 스타일 = "배경색 : 빨간색">
<iframe id = "frame1"src = "TransparentBody.htm"allowTransparency = "true">
</iframe>
<iframe id = "frame2"src = "TransparentBody.htm"allowTransparency = "true"
스타일 = "배경색 : 녹색">
</iframe>
<iframe id = "frame3"src = "TransparentBody.htm">
</iframe>
<iframe id = "frame4"src = "TransparentBody.htm"
스타일 = "배경색 : 녹색">
</iframe>
</body>
이론적으로는 문제가 없지만 IE는 큰 반응을 보이지 않고 여전히 흰색 배경을 가지고 있습니다. 실제로,이 시점에서, 우리는 여전히 하위 페이지의 <body> 태그에 <body bgcolor = "Transparent">를 추가해야합니다. 예제는 다음과 같습니다.
http://img.blog.csdn.net/20140610165850968?watermark/2/text/text/ahr0cdovl2jsb2cuy3nkbi5uzxqva3 vucgvuz19tdwjhbw ==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma ==/dissolve/70/gravity/center
main.html 메인 페이지 코드 :
코드를 복사하십시오
코드는 다음과 같습니다.
<html>
<헤드>
<제목> </title>
</head>
<바디 스타일 = "배경색 : 파란색;">
<테이블
스타일 = "너비 : 100%; 테두리 : 0; 높이 : 100%; 셀 패딩 : 0; 셀 패싱 : 0">
<tr height = "100%">
<td height = "100%"너비 = "30%">
<iframe id = "test1"src = "test1.html"allowtransparency = "true"width = "100%"높이 = "100%"> </iframe> </td>
<td height = "100%"너비 = "40%">
<iframe id = "test2"src = "test2.html"allowtransparency = "true"width = "100%"높이 = "100%"> </iframe> </td>
<td height = "100%"너비 = "30%">
<iframe id = "test3"src = "test3.html"width = "100%"높이 = "100%"> </iframe> </td>
</tr>
</테이블>
</body>
</html>
test1.html 페이지 코드 :
코드를 복사하십시오
코드는 다음과 같습니다.
<html>
<헤드>
<제목> </title>
</head>
<body bgcolor = "Transparent">
<H1> test1 </h1>
</body>
</html>
test2.html 페이지 코드 :
코드를 복사하십시오
코드는 다음과 같습니다.
<html>
<헤드>
<제목> </title>
</head>
<body>
<H1> test2 </h1>
</body>
</html>
test3.html 페이지 코드 :
코드를 복사하십시오
코드는 다음과 같습니다.
<html>
<헤드>
<제목> </title>
</head>
<body>
<H1> test3 </h1>
</body>
</html>
이 작은 예는 주로 iframe 태그의 allowtransparency 속성 응용 프로그램입니다. 속성이 true로 설정되고 iframe에 의해로드 된 서브 페이지의 <body> 태그의 배경색이 투명 (투명)으로 설정됩니다.
allowtransparency는 객체가 투명 할 수 있는지 여부를 설정하거나 가져옵니다.
bgcolor는 물체의 배경색을 설정하거나 가져옵니다.