2017-05-18 7 views
0

3x3サイズの長方形のフルスクリーングリッドでスタックされています。Materializecss長方形のグリッド3x3

これはレイアウトです:ここ

enter image description here

は、私が今持っているものである:ここhttps://jsfiddle.net/hbrnszns/のctrlクリック

は、CSSです:

.rectangle { 
    float: left; 
    width: 100%; 
    padding-bottom: 50%; 
    margin: 1.66%; 
    align-items: center; 
    background-color: #00a388; 
} 

どのように適切に矩形の内部画像を垂直に整列させ、全体を正しく行う方法

答えて

1

既存のレイアウトを使用すると、絶対配置を使用して画像を中央に配置できます。当然position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);

.light-grass { 
 
    background-color: #79bd8f; 
 
} 
 

 
.rectangle { 
 
    width: 100%; 
 
    padding-bottom: 50%; 
 
    margin: 1.66%; 
 
    align-items: center; 
 
    background-color: #00a388; 
 
    position: relative; 
 
} 
 

 
.rectangle > span { 
 
    position: absolute; 
 
    top: 50%; left: 50%; 
 
    transform: translate(-50%,-50%); 
 
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css" rel="stylesheet"/> 
 
<div class="header"> 
 
\t <nav class="light-grass z-depth-0" role="navigation"> 
 
\t </nav> 
 
</div> 
 

 
<div class="row"> 
 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 

 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="row"> 
 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 

 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="row"> 
 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 

 
    <div class="col s4"> 
 
    <div class="rectangle valign-wrapper"> 
 
     <span><img class="work-icon" src="http://placehold.it/100x40"></span> 
 
    </div> 
 
    </div> 
 
</div>

+0

の組み合わせです!私はそれが何らかの理由で底から反応していないことに気づきました、私はこのグリッドが正しいかどうかも分かりません – cygnus

関連する問題