2017-01-11 1 views
-1

페이지 유형의 시장 유형이 있습니다.하지만 제품 (div 요소)이 반응적일 수는 없습니다. 창 크기를 조정하거나 모바일에서 볼 때 끔찍한 것처럼 보입니다. 여기서 내가 뭘 잘못하고 있니?div 요소를 반응 적으로 만드는 방법은 무엇입니까?

<div class="productlayout"> 
     <div class="products"> 
      <div id="col-1"> 
       <img src="originallogo.png"> 
        <hr class="lineunderproduct"> 
        <h3 class="title1">Official Mens T-Shirt</h3> 
        <h4 class="price1">$49.99</h4> 
       <button class="btn btn-5 btn-5a glyphicon glyphicon-shopping-cart"><span>Purchase</span></button> 
      </div> 

      <div id="col-2"> 
       <img src="originallogo.png"> 
        <hr class="lineunderproduct"> 
       <h3 class="title2">Mens Tank</h3> 
        <h4 class="price2">$29.99</h4> 
       <button class="btn btn-5 btn-5a glyphicon glyphicon-shopping-cart"><span>Purchase</span></button> 
      </div> 

      <div id="col-3"> 
       <img src="originallogo.png"> 
        <hr class="lineunderproduct"> 
       <h3 class="title3">Mens Sweatpants</h3> 
        <h4 class="price3">$49.99</h4> 
       <button class="btn btn-5 btn-5a glyphicon glyphicon-shopping-cart"><span>Purchase</span></button> 
      </div> 
     </div> 
    </div> 

CSS

당신은 당신의 디자인이 반응 할 할 미디어 쿼리를 추가하고 또한 항상 반응 디자인

미디어 쿼리의 예에 대한 폭을 제공하기 위해 %를 사용하려고합니다

.productlayout { 
    display: flex; 
    flex-direction: row; 
    height: 500px; 
} 


.products { 
    display: flex; 
    flex-grow: 1; 
    background-color: #c7c4c4; 
    margin: 0px 40px; 
    justify-content: space-around; 
    padding: 30px 0px; 

} 

#col-1 { 
    background: #1d1d1d; 
    width: 320px; 
    order: 1; 
    box-shadow: 0px 0px 1px 1px #000; 
} 

#col-1 img {  /*Product Image placement settings */ 
    width: 75%; 
    display: block; 
    margin: 20px auto 0 auto; 
} 


#col-2 { 
    background: #1d1d1d; 
    width: 320px; 
    order: 2; 
    box-shadow: 0px 0px 1px 1px #000; 
} 

#col-2 img {  /*Product Image placement settings */ 
    width: 75%; 
    display: block; 
    margin: 20px auto 0 auto; 
} 

#col-3 { 
    background: #1d1d1d; 
    width: 320px; 
    order: 3; 
    box-shadow: 0px 0px 1px 1px #000; 
} 

#col-3 img {  /*Product Image placement settings */ 
    width: 75%; 
    display: block; 
    margin: 20px auto 0 auto; 
} 

.lineunderproduct { 
    width: 75%; 
    margin: 0 auto; 
    margin-top: 20px; 
} 

.title1 { 
    color: #e0dcdc; 
    text-align: center; 
    font-size: 20px; 
    font-family: 'Droid Serif', serif; 
} 

.title2 { 
    color: #e0dcdc; 
    text-align: center; 
    font-size: 20px; 
    font-family: 'Droid Serif', serif; 
} 

.title3 { 
    color: #e0dcdc; 
    text-align: center; 
    font-size: 20px; 
    font-family: 'Droid Serif', serif; 
} 

.price1 { 
    color: #959393; 
    font-family: 'Droid Serif', serif; 
    font-size: 15px; 
    text-align: center; 
    font-style: italic; 
} 

.price2 { 
    color: #959393; 
    font-family: 'Droid Serif', serif; 
    font-size: 15px; 
    text-align: center; 
    font-style: italic; 
} 

.price3 { 
    color: #959393; 
    font-family: 'Droid Serif', serif; 
    font-size: 15px; 
    text-align: center; 
    font-style: italic; 
} 


/* Add to Cart Buttons */ 

.btn { 
    border: none; 
    font-family: 'Droid Serif', serif; 
    font-size: 20px; 
    color: #1d1d1d; 
    background: none; 
    cursor: pointer; 
    padding: 20px 80px; 
    display: inline-block; 
    margin: 15px 30px; 
    text-transform: uppercase; 
    letter-spacing: none; 
    outline: none; 
    position: relative; 
    box-shadow: 0px 0px 0px 3px #D4AF37; 
    -webkit-transition: all 0.3s; 
    -moz-transition: all 0.3s; 
    transition: all 0.3s; 
} 

.btn:after { 
    content: ''; 
    position: absolute; 
    z-index: -1; 
    -webkit-transition: all 0.3s; 
    -moz-transition: all 0.3s; 
    transition: all 0.3s; 
} 

.btn-5 { 
    background: #fff; 
    color: #1d1d1d; 
    height: 40px; 
    min-width: 260px; 
    line-height: 30px; 
    font-size: 20px; 
    overflow: hidden; 
    -webkit-backface-visibility: hidden; 
    -moz-backface-visibility: hidden; 
    backface-visibility: hidden; 
} 

.btn-5:active { 
    background: #9053a9; 
    top: 2px; 
} 

.btn-5 span { 
    display: inline-block; 
    letter-spacing: 0.1px; 
    width: 100%; 
    height: 100%; 
    -webkit-transition: all 0.3s; 
    -webkit-backface-visibility: hidden; 
    -moz-transition: all 0.3s; 
    -moz-backface-visibility: hidden; 
    transition: all 0.3s; 
    backface-visibility: hidden; 
} 

.btn-5:before { 
    position: absolute; 
    height: 100%; 
    width: 100%; 
    line-height: 1.5; 
    font-size: 180%; 
    -webkit-transition: all 0.3s; 
    -moz-transition: all 0.3s; 
    transition: all 0.3s; 
} 

.btn-5:active:before { 
    color: #703b87; 
} 

/* Button 5a */ 
.btn-5a:hover span { 
    -webkit-transform: translateY(300%); 
    -moz-transform: translateY(300%); 
    -ms-transform: translateY(300%); 
    transform: translateY(300%); 
} 

.btn-5a:before { 
    left: 0; 
    top: -100%; 
} 

.btn-5a:hover:before { 
    top: 0; 
    /* Hover backgorund change background-color: #308014; */ 
} 

@media (max-width: 800px) { 
    .products { 
     flex-direction: column; 
    } 
+0

이 * 정의 *이 끔찍한 보인다. ** 원하는 ** 디스플레이가 무엇입니까? 당신이 가진 유일한 미디어 쿼리는'flex-direction : column'이며'display : flex' 없이는 아무것도하지 않을 것입니다. 모바일 쿼리를 미디어 쿼리에 추가하거나 미디어 쿼리에 다른 변경 사항을 추가하여 모바일 디스플레이를 변경하십시오. –

+0

@ObsidianAge 임 제품의 1x3 디스플레이를 얻으려고합니다. 각 행에 3을 표시하고 작은 화면에서 볼 때 3x1로 변경하고 싶습니다. – krownfit

답변

0

화면이 작아서 768 픽셀이됩니다

@media only screen and (max-width: 768px) { 

    .products { 
     display:block; 
    } 

    #col-1 {width: 100%;} 
    #col-2 {width: 100%;} 
    #col-3 {width: 100%;} 

    } 

확장 된 충격을 보려면 작은보기.

.productlayout { 
 
    display: flex; 
 
    flex-direction: row; 
 
    height: 500px; 
 
} 
 

 
.products { 
 
    display: flex; 
 
    flex-grow: 1; 
 
    background-color: #c7c4c4; 
 
    margin: 0px 40px; 
 
    justify-content: space-around; 
 
    padding: 30px 0px; 
 

 
} 
 

 
#col-1 { 
 
    background: #1d1d1d; 
 
    width: 33%; 
 
    order: 1; 
 
    box-shadow: 0px 0px 1px 1px #000; 
 
} 
 

 

 

 
#col-2 { 
 
    background: #1d1d1d; 
 
    width: 33%; 
 
    order: 2; 
 
    box-shadow: 0px 0px 1px 1px #000; 
 
} 
 

 
#col-3 { 
 
    background: #1d1d1d; 
 
    width: 33%; 
 
    order: 2; 
 
    box-shadow: 0px 0px 1px 1px #000; 
 
} 
 

 

 
@media only screen and (max-width: 768px) { 
 

 
.products { 
 
\t display:block; 
 
} 
 
    
 
#col-1 {width: 100%;} 
 
#col-2 {width: 100%;} 
 
#col-3 {width: 100%;} 
 
    
 
} 
 
You need to write media queries for different view ports to make your design responsive. 
 

 

 
for smaller screen you can make add this css.
<div class="productlayout"> 
 
     <div class="products"> 
 
      <div id="col-1"> 
 
       <img src="originallogo.png"> 
 
        <hr class="lineunderproduct"> 
 
        <h3 class="title1">Official Mens T-Shirt</h3> 
 
        <h4 class="price1">$49.99</h4> 
 
       <button class="btn btn-5 btn-5a glyphicon glyphicon-shopping-cart"><span>Purchase</span></button> 
 
      </div> 
 

 
      <div id="col-2"> 
 
       <img src="originallogo.png"> 
 
        <hr class="lineunderproduct"> 
 
       <h3 class="title2">Mens Tank</h3> 
 
        <h4 class="price2">$29.99</h4> 
 
       <button class="btn btn-5 btn-5a glyphicon glyphicon-shopping-cart"><span>Purchase</span></button> 
 
      </div> 
 

 
      <div id="col-3"> 
 
       <img src="originallogo.png"> 
 
        <hr class="lineunderproduct"> 
 
       <h3 class="title3">Mens Sweatpants</h3> 
 
        <h4 class="price3">$49.99</h4> 
 
       <button class="btn btn-5 btn-5a glyphicon glyphicon-shopping-cart"><span>Purchase</span></button> 
 
      </div> 
 
     </div> 
 
    </div> 
 

관련 문제