2011-10-18 5 views

답변

1

피들 : http://jsfiddle.net/TFCM4/8/

컨테이너 (#bgs) 안에 4 개의 div를 만들고 요소에 설명적인 클래스 이름을 추가하십시오.

관련 CSS :

html, body { /* Prevent "borders" from appearing */ 
    padding: 0; 
    margin: 0; 
} 
#bgs { /* Let the container fill the whole window */ 
    width: 100%; 
    height: 100%; 
} 
#bgs > div { /* Set the height and width of each div to 50% */ 
    width: 50%; 
    height: 50%; 
} 
.right {float: right;} /* Align to the right */ 
.left {float:left;} /* Align to the left */ 
img { 
    display: block; 
    height: 100%; /* Let the image stretch/shrink when necessary*/ 
    width: 100%; 
} 

HTML :

<div id="bgs"> 
    <div class="top left"> 
     <img src="http://farm7.static.flickr.com/6235/6257586214_7989986f50_z.jpg" /> 
    </div> 
    <div class="top right"> 
     <img src="http://farm7.static.flickr.com/6235/6257586214_7989986f50_z.jpg" /> 
    </div> 
    <div class="bottom left"> 
     <img src="http://farm7.static.flickr.com/6235/6257586214_7989986f50_z.jpg" /> 
    </div> 
    <div class="bottom right"> 
     <img src="http://farm7.static.flickr.com/6235/6257586214_7989986f50_z.jpg" /> 
    </div> 
</div> 

나는 단지 leftright 클래스 이름을 사용했습니다. topbottom이 추가되어 소스가 더보기 좋게 보입니다.


이전 (테이블) 방법 :
가 숨겨져 야 이미지에 visiblity:hidden;를 추가합니다. 이 속성은 요소를 보이지 않게하지만 자리를 "예약 됨"으로 유지합니다.

바이올린 : http://jsfiddle.net/TFCM4/2/

대신 두 개의 테이블을 사용하여, 당신은 하나 개의 테이블에 테이블을 병합 할 수 있습니다, 그리고 더 엉망으로하지 않고 원하는 결과를 얻을 수 있습니다. 바이올린 : http://jsfiddle.net/TFCM4/3/

HTML 구조 :

<table> 
    <tr> 
     <td></td> 
     <td></td> 
    </tr> 
    <tr> 
     <td></td> 
     <td></td> 
    </tr> 
</table> 
+0

감사합니다 롭. 네 부분을 어떻게 전체 창을 덮도록 할 수 있습니까? 현재 그들은 모두 왼쪽 상단 구석으로 부숴 있습니다. 어떻게 든 테이블은 가능한 한 작은 공간을 차지하고 있습니다. 나는 그림을 펼치 길 원합니다. – Randomblue

+0

@Randomblue 단순히'height : 100 %; width : 100 %'를 테이블에 추가하십시오. –

+0

이 피들 http://jsfiddle.net/TFCM4/4/은 자동으로 수평으로 조정되지만 수직으로 조정되지는 않습니다. – Randomblue

0

사용 테이블 같은 것을 제거 그림의 공간을 사용하고 TD에서 IMG을 넣어 다른 사진하지 않을 것입니다

관련 문제