Reputation: 655
I'm really new to flexbox and I was finally able to have my desktop browser display my items as desired. However, in tablet/mobile view the content starts overlapping so I was trying to figure out how to have them respond to one vertical column stacked on top of each other. I know this is done with media queries but I just know what code to use. If anyone has any advice on this that would be greatly appreciated! Thank you!
#recentwork {
background-color: #1DA0A3;
margin-left: auto;
margin-right: auto;
text-align: center;
text-decoration: none;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
}
@media screen and (min-width:600px) {
#recentwork {
flex-wrap: nowrap;
}
}
#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 {
text-decoration: none;
flex: 1;
justify-content: space-between;
}
@media only screen and (min-width: 760px) {
#recentwork img {
width: 300px;
height: 300px;
text-decoration: none;
}
}
.content {
width: 400px;
}
@media only screen and (min-width: 760px) {
#recentwork img {
width: 300px;
height: 300px;
}
#recent{
font-size: 50px;
padding: 40px;
}
}
<section id="skills">
<h2 id="recent">Most Recent Work</h2>
<div id="recentwork">
<div class="parentdiv">
<a href="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<div class="underline">
<h3 class="titles"> Web Design</h3></div>
</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 printer took a galley of type and scrambled it to make a type specimen book.</p>
<a href="" class="more"><h3>See More</h3></a>
</div>
<div class="parentdiv">
<a href="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<h3 class="titles"> Photography</h3>
</a>
<p class="content">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="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<h3 class="titles"> Print</h3>
</a>
<p class="content">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="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<h3 class="titles"> Logos</h3>
</a>
<p class="content">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>
</section>
Upvotes: 2
Views: 10646
Reputation: 8572
Try to:
1. Remove flex-wrap: nowrap
(read more about flex-wrap).
2. Move width: 400px
from .content
element to .parentdiv
element's flex
property.
3. Set justify-content: center
for #recentwork
element.
#recentwork {
background-color: #1DA0A3;
margin-left: auto;
margin-right: auto;
text-align: center;
text-decoration: none;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: stretch;
}
#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 {
max-width: 100%;
text-decoration: none;
flex: 0 1 400px;
justify-content: space-between;
}
@media only screen and (min-width: 760px) {
#recentwork img {
width: 300px;
height: 300px;
text-decoration:none;
}
}
@media only screen and (min-width: 760px) {
#recentwork img{
width: 300px;
height: 300px;
}
#recent{
font-size: 50px;
padding: 40px;
}
}
<section id="skills">
<h2 id="recent">Most Recent Work</h2>
<div id="recentwork">
<div class="parentdiv">
<a href="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<div class="underline">
<h3 class="titles"> Web Design</h3>
</div>
</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 printer took a galley of type and scrambled it to make a type specimen book. </p>
<a href="" class="more"><h3 > See More</h3></a>
</div>
<div class="parentdiv">
<a href="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<h3 class="titles"> Photography</h3>
</a>
<p class="content">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="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<h3 class="titles"> Print</h3>
</a>
<p class="content">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="https://media.flaticon.com/img/tumble.svg" data-lightbox="website" data-title="">
<img src="https://media.flaticon.com/img/tumble.svg" width="200px" height="200px">
<h3 class="titles"> Logos</h3>
</a>
<p class="content">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>
</section>
Upvotes: 3