2017-02-23 34 views
0

所以目前我正在尝试让我的列具有相同的高度,因为它们每个都有点偏离。有没有办法用flexbox做到这一点?然而,我对Flexbox并不是很熟悉,所以如果您有任何建议,请告诉我!谢谢!等宽列可能与flexbox

#recentwork { 
 
    background-color: #1DA0A3; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
    text-align: center; 
 
\t text-decoration: none; 
 
\t 
 

 
} 
 

 
#recentwork a{ 
 
\t text-decoration:none; 
 
} 
 

 
#recent{ 
 
\t padding:20px; 
 
\t text-decoration: none; 
 

 
\t 
 
} 
 
#recentwork img { 
 
    padding: 20px; 
 
    width: 200px; 
 
    height: 200px; 
 
\t 
 
} 
 

 
.more{ 
 
\t text-decoration: none; 
 
\t color:black; 
 
} 
 

 
.more:hover{ 
 
\t color:white; 
 
} 
 

 
.titles{ 
 
\t text-decoration:none; 
 
\t font-size:20px; 
 
\t color:black; 
 
\t 
 
} 
 

 
.parentdiv{ 
 
    display:inline-block; 
 
\t text-decoration: none; 
 
\t 
 
} 
 

 
@media only screen and (min-width: 760px) { 
 
    #recentwork img { 
 
    width: 300px; 
 
    height: 300px; 
 
\t text-decoration:none; 
 
    } 
 
} 
 

 
.content{ 
 
\t width: 400px; 
 
}
<section id="skills"> 
 
<div id="recentwork"> 
 
    <h2 id="recent"> Most Recent Work</h2> 
 

 

 
<div class="parentdiv"> 
 
<a href="http://4vector.com/thumb_data/v4l-125260.jpg" data-lightbox="website" data-title=""> 
 
<img src="http://4vector.com/thumb_data/v4l-125260.jpg" width="200px" height="200px"> 
 
<div class="underline"> 
 
<h3 class="titles"> Web Design</h3></div> 
 
</a> 
 

 
<p class="content">not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 
 

 
<a href="" class="more"><h3 > See More</h3></a> 
 
</div> 
 
    
 
    <div class="parentdiv"> 
 
<a href="http://4vector.com/thumb_data/v4l-125260.jpg" data-lightbox="website" data-title=""> 
 
<img src="http://4vector.com/thumb_data/v4l-125260.jpg" width="200px" height="200px"> 
 
<h3 class="titles"> Photography</h3> 
 
</a> 
 
<p class="content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown </p> 
 

 
<a href="" class="more"><h3 > See More</h3></a> 
 
</div> 
 

 
    
 
    <div class="parentdiv"> 
 
<a href="http://4vector.com/thumb_data/v4l-125260.jpg" data-lightbox="website" data-title=""> 
 
<img src="http://4vector.com/thumb_data/v4l-125260.jpg" width="200px" height="200px"> 
 
<h3 class="titles"> Print</h3> 
 
</a> 
 
<p class="content">printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p> 
 

 
<a href="" class="more"><h3 > See More</h3></a> 
 
</div> 
 

 
    <div class="parentdiv"> 
 
<a href="http://4vector.com/thumb_data/v4l-125260.jpg" data-lightbox="website" data-title=""> 
 
<img src="http://4vector.com/thumb_data/v4l-125260.jpg" width="200px" height="200px"> 
 
<h3 class="titles"> Logos</h3> 
 
</a> 
 

 
<p class="content">printer took a galley of type and scrambled it to make a type specimen book. It has survived </p> 
 
<a href="" class="more"><h3 > See More</h3></a> 
 
</div> 
 
    
 

 
</div> 
 
</section>

回答

1

This是你需要的。
以上提到的答案,你必须把每一个divsection,无论你使用什么,在一个div。
然后,您将该父母div归属display: flex。如果你想让你的所有子元素具有相同的宽度,你可以使用flex: 1flex-grow: 1

如果你想尝试一下,你可以使用flexbox,试试this。这是一个不错的游乐场,您可以玩这些值并看看会发生什么。我希望这有助于:)

1

第一招<h2 id="recent"> Most Recent Work</h2>#recentwork所以你的Flex项目仅仅是.parentdiv

然后将display:flex加到#recentwork

这会给你的列高度相等。

flex:1添加到.parentdiv将使您的列宽度相等。