Issues with organizing a Portfolio Gallery

Currently, I am in the process of creating a portfolio page and I am utilizing placeholder images until I have actual projects to showcase. I am encountering difficulties trying to structure one large image with two to four smaller images underneath it, all evenly filling a container.

Despite attempting to follow tutorials from W3 Schools on Image Grids, Responsive Image Grids, and Portfolio Galleries, I have not been successful.

Below is the code snippet causing issues:

.content-section {
  margin-bottom: 20px;
  width: 100%;
  padding: 20px;
  display: flex;
  align-items: center;
}

.content-section div {
  border-left: 3px solid gray;
  width: 75%;
  padding: 20px;
  text-align: left;
}

.content-section h2 {
  width: 15%;
  font-family: 'Courier New', Courier, monospace;
  display: flex;
  justify-content: right;
  padding-right: 10px;
}

.yoga img {
  width: 100%;
  border: 5px solid steelblue;
}
<section id="my-work" class="content-section">
  <h2>Work</h2>
  <div class="yoga">
    <img src="img\yoga.jpg" alt="Yoga Project">
  </div>
</section>

The issue arises when I attempt to incorporate additional images. The border between the h2 heading and the images either shifts or duplicates next to the new images.

I trust this question adheres to the guidelines, as I reviewed them prior to posting. I would greatly appreciate any assistance in directing me towards a solution! I have included a link to the live website as well.

Thank you!!

Answer №1

To adjust the size of your images within a flex layout, make use of the flex-shrink property. Additionally, consider implementing a CSS design framework to efficiently resize your images before arranging them in the layout.

When working with flex items, the flex-shrink property determines how much an item can shrink in size if necessary. This allows items to resize proportionally within the flex container when there is limited available space.

Answer №2

:) You could resolve this problem by utilizing a flex box. Here's what you need to do.

  1. Update the index.html file
 <div class="flex-container">
   <img class="img1" src="img/snow.jpg?raw=true" alt="Snow Report">
   <div class="flex-container-sub">
     <img src="img/trail-running.jpg?raw=true" alt="Yoga Project">
     <img src="img/yoga.jpg?raw=true" alt="Trail Finder">
   </div>
 </div>
  1. Update the style.css file
.flex-container-sub {
  width: 100%;
  display: flex;
  justify-content: 'space-between';
}

.flex-container-sub img:nth-child(1) {
  width: 50%;
  padding-top: 10px;
}

.flex-container-sub img:nth-child(2) {
  width: 50%;
  padding-top: 10px;
  padding-left: 10px;
}

.content-section .flex-container {
  border-left: 3px solid gray;
  width: 75%;
  padding: 20px;
  text-align: left;
}

I also removed the div selector from content-section to prevent any unintended styling. This shouldn't affect the current issue.

In this solution, I've grouped the two additional images you mentioned below the main image within a flex container. The flex container is set to distribute items evenly with justify-content: space-between. The nth-child selectors are used to add padding to each of the images, ensuring they are spaced out properly. You can view more details on this behavior here.

By utilizing a flex box layout, the width of the images automatically adjusts based on padding. The first image is given a width of 50% and a top padding, while the second one is given a width of 50% with padding on the left side. Creating separate classes for these images and applying the styles is also a viable approach!

For a live demonstration, you can check out this demo link.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bootstrap Collapse Plugin allows you to toggle the visibility of

Is there a way for all the multicollapses to automatically close when a new one is opened? I specifically want the "Accordion Item # 2.1" to collapse when I click on "Accordion Item # 1" or "Accordion Item # 3". Currently, my code only closes "Accordion It ...

What is the method for embedding a concealed form within a table?

I am a beginner in HTML and RoR. I am trying to include a button inside a table that will submit a hidden form. However, I am facing an issue where the button is not showing up in the generated HTML. <table class="centerBox"> <h3>Search Resu ...

Showing information from the data text option

I'm having trouble displaying text below the cube. The code works fine in a standalone fiddle, but it doesn't work when I incorporate it into my project. Can someone help me figure out how to show the value of data-text="Cube1"? Code t ...

Determine whether to show or hide a div based on the width of the

Is there a way to dynamically hide a div using Bootstrap 4 based on the screen width? Can this be achieved without using JavaScript? I am particularly interested in hiding certain text elements that are not relevant on smaller screens, such as mobile de ...

Eliminating the unwanted line breaks that are automatically inserted when integrating JavaScript with HTML code

Hey everyone, I'm new to web development and could really use some assistance. I am currently working on a website that shows the weather forecast for the next four days, using SimpleWeather.js. In my JavaScript, I want to display the High & Low temp ...

How to Style Background with CSS on the Server-Side? (Including Links and Hover Effects)

I'm facing a dilemma in choosing between an ASP.NET control and an HTML element for creating a button with a CSS-defined background that changes on hover... 1. Initially, it seems the ASP.NET ImageButton control is not suitable for this purpose becau ...

Adding a Bootstrap carousel to an HTML page may cause the inner items to inexplic

I have been working on creating a User Projects section, and I wanted to display the projects in a carousel format. However, when I tried to import Bootstrap carousels, my items suddenly disappeared. Since I am coding on a tablet and not a computer, I am n ...

Is there a better method to determine the width when utilizing the jQuery UI resizable feature for improved efficiency?

I'm currently working on a website that features a resizable sidebar. I want the icons and text within the sidebar to shrink proportionally when the user resizes it. Right now, I have implemented an if statement to check if the sidebar's width fa ...

Learning how to use Express.js to post and showcase comments in an HTML page with the help of Sqlite and Mustache templates

I am facing a persistent issue while trying to post new comments to the HTML in my forum app. Despite receiving various suggestions, I have been struggling to find a solution for quite some time now. Within the comments table, each comment includes attrib ...

Tips for showing nested JSON data in a PrimeNG table within Angular version 7

I am struggling to display nested json data in a PrimeNG table. When I retrieve the data using an HTTP service, it appears as [object][object] when displayed directly in the table. What I want is to show the nested json data with keys and values separated ...

Ways to stop VoiceOver from selecting the background content when a modal is open

Is there a way to prevent VoiceOver from reading the content behind a modal? I tried using aria-modal=true, but it seems VoiceOver does not support this feature by default like NVDA and JAWS do. I found more information about this on . According to the in ...

How can we prevent the modal from extending beyond the boundaries of the phone screen when zoomed in

I am currently developing a web application that features a large content page, specifically a map which should display detailed information upon zooming in similar to Google Maps. The interactive elements on my map are clickable, triggering a modal popup ...

Is there a solution or workaround for the issue of fake anti-aliasing in Microsoft Edge when it comes to the border of sticky headers using Bootstrap 4?

In my current project, I came across a Pen shared by Balaji731 on Bootstrap 4 table with the scrollable body and header fixed. While testing the Pen in Microsoft Edge, I noticed that when <th> borders are enabled, they disappear while scrolling, cre ...

Conceal the HTML input element until the JavaScript has finished loading

Currently, I am using a JQuery plugin to style a form input with type 'file'. The plugin adds a new span over the input element to create a mask effect and encloses everything in a div. However, there is an issue where the standard HTML input box ...

Form with missing input fields submits nothing to the server

I created a Node project with a single view page for users to access information. When I use an HTML form to send data, the content is empty. I have verified multiple times using Postman that the information is being saved successfully when sent with the P ...

Is it possible for a Bootstrap modal dialog to overlay another dialog window?

<button class="btn" onClick="$('#firstModal').modal('show');">Click Here</button> <!-- Modal --> <div id="firstModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden=" ...

Submitting a form with missing required information because the placeholder attribute is being used

I'm encountering an issue with my form where required fields can be submitted without any input. I want to use placeholder text, but it seems to be treated as a value, causing the form to submit successfully. I am utilizing the HTML5 'placeholde ...

Exploring Browser History using Cascading Style Sheets

Currently, I am in need of researching a topic for my University project. Unfortunately, the internet has not provided me with any information on this specific subject. The task at hand is as follows: "How and under what circumstances can one uncover ...

Apply the CSS property to all divs with a shared class using jQuery

I am facing an issue with applying the CSS property 'z-index:99' to multiple divs that have the same class name. I want this CSS to be applied when clicking on a play button using jQuery. Currently, it only works for the first Play Button and I w ...

One solitary table is successfully loaded

I am facing an issue with my setup where I have two HTML tables and a PHP file that loads every 1 second through AJAX to pass information to these tables. Here is the HTML structure: <div style='float: left;'> <br><br> & ...