2017-12-28 2 views
0

콘텐츠가 포함 된 6 개의 개별 상자를 만들려고합니다. 그러나 세로로 구분하지 않고 가로로만 분리 할 수 ​​있습니다. 예를 들어 상자는 '너비'를 사용하여 가로 방향으로 간격을 두어 배치 할 수 있지만이 이미지의 상자를이 이미지로 이동하려고하면 세로로 분리되어 두 개가 아닌 쌍으로 머물러 있지 않습니다. 누구든지 해결책을 안다면, 크게 감사하겠습니다. 감사합니다 :)html/css에서 그룹 콘텐츠를 세로로 분리하는 방법은 무엇입니까?

body { 
 
     background-color: #323232; 
 
     max-width: 960px; 
 
     padding: 0; 
 
     margin: 0; 
 
     font-family: Lato; 
 
     } 
 

 
     nav a { 
 
     color: #fff; 
 
     text-decoration: none; 
 
     padding: 20px 25px; 
 
     display: inline-block; 
 
     } 
 

 
     .fixed-header, .fixed-footer { 
 
     background: #333; 
 
     color: #fff; 
 
     width: 100%; 
 
     position: fixed; 
 
     text-align: center; 
 
     z-index: 10; 
 
     background-color: #202020; 
 
     } 
 

 
     .fixed-header { 
 
     top: 0; 
 
     } 
 

 
     .fixed-footer { 
 
     bottom: 0; 
 
     padding: 20px 0px; 
 
     } 
 

 
     .fixed-header a:hover { 
 
     color: #c1c1c1; 
 
     } 
 

 
     .fixed-footer a { 
 
     color: #fff; 
 
     font-weight: lighter; 
 
     text-decoration: none; 
 
     } 
 

 
     .group-content { 
 
     max-width: 960px; 
 
     text-align: center; 
 
     } 
 

 
     .group-content h3 { 
 
     font-weight: normal; 
 
     font-size: 20px; 
 
     color: white; 
 
     } 
 

 
     .group-content p { 
 
     font-weight: lighter; 
 
     font-size: 20px; 
 
     color: white; 
 
     } 
 

 
     .content { 
 
     display: inline-block; 
 
     width: 30%; 
 
     background-color: #202020 
 
     } 
 

 
     @font-face { 
 
     font-family: "Lato"; 
 
     font-weight: normal; 
 
     font-style: normal; 
 
     src: url('fonts/Lato-Regular.eot'), 
 
     src: url('fonts/Lato-Regular.eot?#iefix') format('embedded-opentype'), 
 
     url('fonts/Lato-Regular.ttf') format('truetype'), 
 
     url('fonts/Lato-Regular.woff') format('woff'), 
 
     url('fonts/Lato-Regular.woff2') format('woff2'); 
 
     } 
 

 
     @font-face { 
 
     font-family: "Lato"; 
 
     font-weight: bold; 
 
     font-style: normal; 
 
     src: url('fonts/Lato-Bold.eot'), 
 
     src: url('fonts/Lato-Bold.eot?#iefix') format('embedded-opentype'), 
 
     url('fonts/Lato-Bold.ttf') format('truetype'), 
 
     url('fonts/Lato-Bold.woff') format('woff'), 
 
     url('fonts/Lato-Bold.woff2') format('woff2'); 
 
     } 
 

 
     @font-face { 
 
     font-family: "Lato"; 
 
     font-weight: lighter; 
 
     font-style: normal; 
 
     src: url('fonts/Lato-Light.eot'), 
 
     src: url('fonts/Lato-Light.eot?#iefix') format('embedded-opentype'), 
 
     url('fonts/Lato-Light.ttf') format('truetype'), 
 
     url('fonts/Lato-Light.woff') format('woff'), 
 
     url('fonts/Lato-Light.woff2') format('woff2'); 
 
     }
<!DOCTYPE html> 
 

 
<html lang="en"> 
 

 
<head> 
 
    <title>Kumo99.cf</title> 
 
    <meta charset="UTF-8"> 
 
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
 
    <link rel="icon" href="favicon.ico"> 
 
</head> 
 

 
<body> 
 

 
<div class="fixed-header"> 
 
    <nav> 
 
    <a href="index.html">HOME</a> 
 
    <a href="projects.html">PROJECTS</a> 
 
    <a href="about.html">ABOUT</a> 
 
    </nav> 
 
</div> 
 

 
<div class="fixed-footer"> 
 
<a href="https://steamcommunity.com/id/kumo99">Made by Kumo © 2018</a> 
 
</div> 
 

 
<div class="group-content"> 
 
    <div class="content"> 
 
    <img src="https://i.imgur.com/Xde6duk.png"> 
 
    <h3>Arma 3: Exile Server</h3> 
 
    <p>A project for improving the exile mod.</p> 
 
    </div> 
 

 
    <div class="content"> 
 
    <img src="https://i.imgur.com/Xde6duk.png"> 
 
    <h3>Reserved Space</h3> 
 
    <p>Reserved space for future projects</p> 
 
    </div> 
 

 
    <div class="content"> 
 
    <img src="https://i.imgur.com/Xde6duk.png"> 
 
    <h3>Reserved Space</h3> 
 
    <p>Reserved space for future projects</p> 
 
    </div> 
 

 
    <div class="content"> 
 
    <img src="https://i.imgur.com/Xde6duk.png"> 
 
    <h3>Reserved Space</h3> 
 
    <p>Reserved space for future projects</p> 
 
    </div> 
 

 
    <div class="content"> 
 
    <img src="https://i.imgur.com/Xde6duk.png"> 
 
    <h3>Reserved Space</h3> 
 
    <p>Reserved space for future projects</p> 
 
    </div> 
 

 
    <div class="content"> 
 
    <img src="https://i.imgur.com/Xde6duk.png"> 
 
    <h3>Reserved Space</h3> 
 
    <p>Reserved space for future projects</p> 
 
    </div> 
 
</div> 
 

 
</body> 
 
</html>

+0

'.content {margin-bottom : 4px;} ' – Chiller

+0

작동하지 않아 상자의 배경색이 사라집니다. –

답변

0

나는 레이아웃으로 jsfiddle을 만들어 나는 각각의 내용의 크기를 제한하려면이 규칙을 추가는 기본적으로 https://jsfiddle.net/rqvg3fd2/

작동하도록 변경 한 차단 :

.content >* { 
    max-width: 220px; 
    text-align: center; 
    margin: 0; 
} 

그런 다음 .group-content에 마지막 3 줄을 추가했습니다. 플렉스 그리드로 만들 수 있습니다. flex-wrap : wrap이 내용을 둘러 쌉니다.

.group-content { 
    max-width: 960px; 
    text-align: center; 
    display: flex; 
    flex-wrap: wrap; 
    justify-content: space-evenly; 
} 

나는 또한 .content 열로 플렉스 그리드를 만들어 행

.content { 
    width: 30%; 
    background-color: #202020; 
    display: flex; 
    flex-direction: column; 
    padding-bottom: 20px; 
    align-items: center; 
    margin-top: 20px; 
} 

그리고 마지막에서 공간으로 그것을 상단에 여백을 준, 나는 상단에 여백을 추가 H3을 빨간색 상자에서 분리합니다.

.group-content h3 { 
    margin-top: 10px; 
    font-weight: normal; 
    font-size: 20px; 
    color: white; 
} 
+0

자세한 답변을 주셔서 감사 드리며 문제를 해결했을뿐만 아니라 새로운 것을 배웠습니다. –

+0

내 대답이 정확 했으므로 허용 된 것으로 표시해주세요. –

관련 문제