宽度相等的列可能带有flexbox

时间:2017-02-23 06:01:06

标签: html css flexbox

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



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

}

#recentwork a{
	text-decoration:none;
}

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

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

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

.more:hover{
	color:white;
}

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

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

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

.content{
	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>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

首先在<h2 id="recent"> Most Recent Work</h2>之外移动#recentwork,以便您的展示项仅为.parentdiv

然后将display:flex添加到#recentwork

这将使您的列具有相同的高度。

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

答案 1 :(得分:1)

This是正确的。
Aso上面提到的答案,你必须将每个divsection,无论你使用什么,放在div中。
然后你给父母div display: flex。如果您希望所有子元素具有相同的宽度,则可以使用flex: 1flex-grow: 1

如果您想尝试一下,可以使用flexbox,请尝试this。这是一个很好的游乐场,你可以玩价值观,看看会发生什么。我希望这会有所帮助:)

相关问题