2016-12-11 2 views
0

레이아웃의 기본 온라인 상점 유형을 만들려고합니다. 그냥 아주 기본적인 초보자 CSS와 HTML사진 4 장을 나란히 정렬하려면 어떻게해야하나요?

+1

사용 CSS 플렉스, CSS 트릭은 –

+0

당신이, 당신도 HTML을 입력하는 방법을 모른다 의미 멋진 설명을 가지고 있으며, 당신은 우리를 위해 무료로 작업에 우리를 물어? – Obink

답변

2

다음은 플렉스 스타일을 사용하는 방법입니다. This은 플렉스 박스를 배우기에 좋은 자료입니다. (뭔가 잊어 버릴 때마다 내가 간다.)

#container{ 
 
    display: flex; /*specifies that the items in the container should abide by flex styling*/ 
 
    flex-direction: row; /*aligns the items in the container in a row*/ 
 
} 
 

 
.imgContainer{ 
 
    text-align: center; /*aligns the text in the center*/ 
 
    padding: 2%; /*adds some extra white space around images*/ 
 
}
<!-- container element for all of the content. 
 
It will line up the imgContainers in a row--> 
 
<div id="container"> 
 
    <!--imgContainers will contain each img and text combination --> 
 
    <div class="imgContainer"> 
 
    <img src="https://www.nasa.gov/sites/default/files/styles/image_card_4x3_ratio/public/thumbnails/image/leisa_christmas_false_color.png?itok=Jxf0IlS4"> 
 
    <p>This is an image</p> 
 
    </div> 
 
    <div class="imgContainer"> 
 
    <img src="https://www.nasa.gov/sites/default/files/styles/image_card_4x3_ratio/public/thumbnails/image/leisa_christmas_false_color.png?itok=Jxf0IlS4"> 
 
    <p>This is an image</p> 
 
    </div> 
 
    <div class="imgContainer"> 
 
    <img src="https://www.nasa.gov/sites/default/files/styles/image_card_4x3_ratio/public/thumbnails/image/leisa_christmas_false_color.png?itok=Jxf0IlS4"> 
 
    <p>This is an image</p> 
 
    </div> 
 
    <div class="imgContainer"> 
 
    <img src="https://www.nasa.gov/sites/default/files/styles/image_card_4x3_ratio/public/thumbnails/image/leisa_christmas_false_color.png?itok=Jxf0IlS4"> 
 
    <p>This is an image</p> 
 
    </div> 
 
</div>