2017-11-10 1 views
1

일부 CSS에 문제가 있습니다. 화면 크기가 1024px보다 작아지면 스택하려는 3 개의 뉴스 열이 있습니다. 그러나 코드를 통해 지금은 사라졌습니다. 이상하게도 저는 스택해야하는 행이 2 개 있습니다. 하나는 .row이고 다른 하나는 작동하지 않는 .newsrow입니다.CSS 플렉스 박스가 겹쳐지지 않습니다.

CSS :

/*Neccasary for alignment for some reason, have to solve this issue later*/ 
* { 
    box-sizing: border-box; 
} 
/*Style van overall body*/ 
body { 
    margin: 0; 
    background-color: #000; 
    color: white; 
} 
/*Style voor h2 tekst*/ 
h2 { 

} 

/* Style the header */ 
.header { 
    background-color: #222222; 
    padding: 50px; 
    text-align: center; 
} 

/* Container for flexboxes */ 
.row { 
    display: -webkit-flex; 
    display: flex; 
} 

.contentrow { 
    display: -webkit-flex; 
    display: flex; 
} 

/* 3 middelse columns (Grootte wordt bepaald in html doc (Standaard: Flex-Grow: 4;)) */ 
.column { 
    -webkit-flex: 1; 
    -ms-flex: 1; 
    flex: 1; 
    padding: 0px; 
    text-align: center; 
} 

.middlemenu { 
    -webkit-flex: 1; 
    -ms-flex: 1; 
    flex: 1; 
    padding: 0px; 
    height: 50px; 
    text-align: center; 
    margin: 0px; 
} 

/* Container for newsboxes */ 
.newsrow { 
    display: -webkit-flex; 
    display: flex; 
} 

.newsbox { 
    -webkit-flex: 1; 
    -ms-flex: 1; 
    flex: 1; 
    margin-top: 30px; 
    margin-left: 30px; 
    margin-right: 30px; 
    margin-bottom: 10px; 
    min-width: 200px; 
    height: 225px; 
    text-align: center; 
    background-color: #999999; 
    } 

/* Style van de footer. */ 
.footer { 
    background-color: #222222; 
    padding: 10px; 
    text-align: center; 
} 

/* Zorgt ervoor dat bij het krimpen de flexboxes stapelen i.p.v. naast elkaar blijven staan.*/ 
@media (max-width: 1024px) { 
    .row { 
     -webkit-flex-direction: column; 
     flex-direction: column; 
     display: block; 
    } 

    .newsrow { 
     -webkit-flex-direction: column; 
     flex-direction: column; 
     display: flex;  
    } 

} 

HTML :

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<title>CSS Template</title> 
<meta charset="utf-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" type="text/css" href="css/style.css"> 
</head> 
<body> 

<div class="header"> 
    <h2>234234</h2> 
</div> 

<div class="row"> 
    <div class="column" style="background-color:#444; padding: 10px;">1337 WHEH</div> 
    <div class="column" style="background-color:#555; flex-grow: 4;"> 
     <div class="middlemenu" style="background-color:#777"> 
      <!--Hier komt menu content--> 
     </div> 
     <div class="newsrow"> 
      <div class="newsbox"></div> 
      <div class="newsbox"></div> 
      <div class="newsbox"></div> 
     </div> 
    </div> 
    <div class="column" style="background-color:#666; padding: 10px;">1337 WHEEEH</div> 
</div> 
<div class="footer"> 
    <p>Footer</p> 
</div> 

</body> 
</html> 

문제 : 내가 옆에 서로의 상단 대신 측면에 .row 스택 내에서 화면 작은 모든 것을 할 때. 그러나 .newsrow의 모든 내용은 1023px 너비에 도달하면 사라집니다.

도와주세요.

+0

'.column'에서 단순히'height'을 제거하십시오. – sol

+0

그걸 시도해 보았습니다. 내 문제 중 다른 문제가 해결되었지만 스택 대신 여전히 사라질 것입니다. –

+0

그것은 이상한 일입니다. 그들은 아래 답변에서 저를 위해 쌓아 둡니다. 간섭을 일으킬 수있는 추가 코드가 있습니까? – sol

답변

0

귀하의 문제는 당신이 예를

/*Neccasary for alignment for some reason, have to solve this issue later*/ 
 
* { 
 
    box-sizing: border-box; 
 
} 
 
.row { 
 
    display: -webkit-flex; 
 
    display: flex; 
 
} 
 
.contentrow { 
 
    display: -webkit-flex; 
 
    display: flex; 
 
} 
 

 
/* 3 middelse columns (Grootte wordt bepaald in html doc (Standaard: Flex-Grow: 4;)) */ 
 
.column { 
 
    -webkit-flex: 1; 
 
    -ms-flex: 1; 
 
    flex: 1; 
 
    padding: 0px; 
 
    text-align: center; 
 
} 
 

 
.middlemenu { 
 
    -webkit-flex: 1; 
 
    -ms-flex: 1; 
 
    flex: 1; 
 
    padding: 0px; 
 
    height: 50px; 
 
    text-align: center; 
 
    margin: 0px; 
 
} 
 

 
/* Container for newsboxes */ 
 
.newsrow { 
 
    display: -webkit-flex; 
 
    display: flex; 
 
} 
 

 
.newsbox { 
 
    -webkit-flex: 1; 
 
    -ms-flex: 1; 
 
    flex: 1; 
 
    margin-top: 30px; 
 
    margin-left: 30px; 
 
    margin-right: 30px; 
 
    margin-bottom: 10px; 
 
    min-width: 200px; 
 
    text-align: center; 
 
    background-color: yellow; 
 
    } 
 

 
/* Zorgt ervoor dat bij het krimpen de flexboxes stapelen i.p.v. naast elkaar blijven staan.*/ 
 
@media (max-width: 1024px) { 
 
    .row { 
 
     -webkit-flex-direction: column; 
 
     flex-direction: column; 
 
    } 
 

 
    .newsrow { 
 
     -webkit-flex-direction: column; 
 
     flex-direction: column; 
 
    } 
 

 
}
<div class="row"> 
 
    <div class="column" style="background-color:red; padding: 10px;">1337 WHEH</div> 
 
    <div class="column" style="background-color:blue; flex-grow: 4;"> 
 
     <div class="middlemenu" style="background-color:orange"> 
 
      <!--Hier komt menu content--> 
 
     </div> 
 
     <div class="newsrow"> 
 
      <div class="newsbox">lIn velit voluptate </div> 
 
      <div class="newsbox">asa<div> 
 
      <div class="newsbox">asdas</div> 
 
     </div> 
 
    </div> 
 
    <div class="column" style="background-color:green; padding: 10px;">112389127389721 WHEEEH</div> 
 
</div>
보면, 컬럼의 높이를 설정하는 것입니다,739,

+0

높이가 제거되었습니다. 문제를 해결하지 못했습니다. –

+0

여기에서 열을 볼 수 있습니다. https://jsfiddle.net/2haj8eef/2/ –

0

는에 height 속성을 제거 .column

fiddle

* { 
 
    box-sizing: border-box; 
 
} 
 

 

 
/*Style van overall body*/ 
 

 
body { 
 
    margin: 0; 
 
    background-color: #000; 
 
    color: white; 
 
} 
 

 

 
/*Style voor h2 tekst*/ 
 

 
h2 {} 
 

 

 
/* Style the header */ 
 

 
.header { 
 
    background-color: #222222; 
 
    padding: 50px; 
 
    text-align: center; 
 
} 
 

 

 
/* Container for flexboxes */ 
 

 
.row { 
 
    display: -webkit-flex; 
 
    display: flex; 
 
} 
 

 
.contentrow { 
 
    display: -webkit-flex; 
 
    display: flex; 
 
} 
 

 

 
/* 3 middelse columns (Grootte wordt bepaald in html doc (Standaard: Flex-Grow: 4;)) */ 
 

 
.column { 
 
    -webkit-flex: 1; 
 
    -ms-flex: 1; 
 
    flex: 1; 
 
    padding: 0px; 
 
    /* remove this */ 
 
    /* height: 300px; */ 
 
    text-align: center; 
 
} 
 

 
.middlemenu { 
 
    -webkit-flex: 1; 
 
    -ms-flex: 1; 
 
    flex: 1; 
 
    padding: 0px; 
 
    height: 50px; 
 
    text-align: center; 
 
    margin: 0px; 
 
} 
 

 

 
/* Container for newsboxes */ 
 

 
.newsrow { 
 
    display: -webkit-flex; 
 
    display: flex; 
 
} 
 

 
.newsbox { 
 
    -webkit-flex: 1; 
 
    -ms-flex: 1; 
 
    flex: 1; 
 
    margin-top: 30px; 
 
    margin-left: 30px; 
 
    margin-right: 30px; 
 
    margin-bottom: 10px; 
 
    min-width: 200px; 
 
    height: 225px; 
 
    text-align: center; 
 
    background-color: #999999; 
 
} 
 

 

 
/* Style van de footer. */ 
 

 
.footer { 
 
    background-color: #222222; 
 
    padding: 10px; 
 
    text-align: center; 
 
} 
 

 

 
/* Zorgt ervoor dat bij het krimpen de flexboxes stapelen i.p.v. naast elkaar blijven staan.*/ 
 

 
@media (max-width: 1024px) { 
 
    .row { 
 
    -webkit-flex-direction: column; 
 
    flex-direction: column; 
 
    } 
 
    .newsrow { 
 
    -webkit-flex-direction: column; 
 
    flex-direction: column; 
 
    } 
 
}
<div class="header"> 
 
    <h2>234234</h2> 
 
</div> 
 

 
<div class="row"> 
 
    <div class="column" style="background-color:#444; padding: 10px;">1337 WHEH</div> 
 
    <div class="column" style="background-color:#555; flex-grow: 4;"> 
 
    <div class="middlemenu" style="background-color:#777"> 
 
     <!--Hier komt menu content--> 
 
    </div> 
 
    <div class="newsrow"> 
 
     <div class="newsbox"></div> 
 
     <div class="newsbox"></div> 
 
     <div class="newsbox"></div> 
 
    </div> 
 
    </div> 
 
    <div class="column" style="background-color:#666; padding: 10px;">1337 WHEEEH</div> 
 
</div> 
 
<div class="footer"> 
 
    <p>Footer</p> 
 
</div>

0

이 시도 도움이되기를 바랍니다 :

@media (max-width: 1024px) { 
    .newsrow { 
    display:block; 
    } 
    .newsbox{ 
    display:flex; 
    } 
    .column { 
    height:auto; 
    } 

} 

https://jsfiddle.net/n3e5qksh/1/

+0

시도해 보았습니다. 이제는 눈에 잘 띄지 만 스택 대신 화면 밖으로 이동합니다. –

+0

높이 사용 : 열 클래스에 자동으로 작동하는 것 같습니다 – danielarend

0

당신은 당신의 스타일에 .column을 제거해야합니다. 이 사이트를 더 촘촘하게 만들고 싶다면 더 많은 미디어 쿼리를 추가 할 수 있습니다. 나는 이것을 다음과 같이 개인적으로 사용한다 :

/*Responsive Design*/ 
@media only screen and (min-width: 300px){ 
.cardinhalt{ 
    width: calc(100% - 10px) !Important; 
} 
} 
/*Responsive Design*/ 
@media only screen and (min-width: 600px){ 
.cardinhalt{ 
    width: calc(50% - 10px) !Important; 
} 
} 
/*Responsive Design*/ 
@media only screen and (min-width: 900px){ 
.cardinhalt{ 
    width: calc(33.33% - 10px) !Important; 
} 
} 
/*Responsive Design*/ 
@media only screen and (min-width: 1200px){ 
.cardinhalt{ 
    width: calc(25% - 10px) !Important; 
} 
} 
/*Responsive Design*/ 
@media only screen and (min-width: 1200px){ 
.cardContainer{ 
    width: 1200px; 
    position: relative; 
    margin: auto; 
} 
0

. 컬럼 높이는 그것을 제거한 후에 문제를 해결했다. 상자에 정보를 입력하자마자 상자가 작동했습니다.

+0

답변으로 게시 할 필요가 없습니다. 수락 된 답변에 댓글을 달 수 있습니다. – sol

+0

@ovokuro 나도 안다.하지만 같은 대답을하는 사람들이 몇 명 있었고, 첫 번째 사람은 반응 할 수 없었다. –

관련 문제