flexible design using flexbox with image overflow and responsive footer

I created a website and utilized flexbox for designing the layout.

The page structure is quite simple, consisting of only 3 tags:

<header>

<section>

<footer>

[index.html]

<html>
<head>
  <link rel="stylesheet" type="text/css" href="style.css">

</head>
<body>
  <header>
    <div class="header__left">
      <span>Email here or call</span>
    </div>
    <div class="header__center">
      <img src="img/logo.png">
    </div>
    <div class="header__right">
      <a href="#">About us</a>
      <a href="#">Our Work</a>
      <a href="#">Our People</a>
    </div>
  </header>
  <section>
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
  </section>
  <footer>
    THIS IS FOOTER
  </footer>
</body>
</html>

[style.css]

html, body {
  padding: 0;
  margin: 0;
}
header {
  display: flex;
  height: 70px;
}
.header__left {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.header__center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.header__right {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
section {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  max-height: 100vh;
}
section img {
  max-width: 25vw;
}

Additionally, I included max-width: 25vw; to showcase 4 images per row.

Upon entering the site, the layout appears as shown in this screenshot: https://i.sstatic.net/8WJrl.png

Everything seems to work well on smaller browser sizes. However, upon enlarging the browser window,

This issue arises where the <section> element overlaps with the <footer>.

Do you have any recommendations on how to avoid this problem?

Thank you.

Answer №1

Take a look at this code snippet! Simply adjust the height and width to 100% https://jsfiddle.net/ksmLwngp/4/

html, body {
  padding: 0;
  margin: 0;
}
header {
  display: flex;
  height: 70px;
}
.header__left {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.header__center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.header__right {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
section {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  max-height: 100vh;
}
section img {
  max-width: 25vw;
}

  .imgbox {
    width:100%;
    height: 100%;
  }

<html>
<head>
  <link rel="stylesheet" type="text/css" href="style.css">

</head>
<body>
  <header>
    <div class="header__left">
      <span>Contact us via email or call</span>
    </div>
    <div class="header__center">
      <img src="img/logo.png">
    </div>
    <div class="header__right">
      <a href="#">About us</a>
      <a href="#">Our Work</a>
      <a href="#">Our People</a>
    </div>
  </header>
  <section>
  <div class="imgbox">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    <img src="./img/dummy.jpg" alt="Sample photo">
    </div>
  </section>
  <footer>
    THIS IS FOOTER
  </footer>
</body>
</html>

Answer №2

delete the max-height: 100vh; instance from this fiddle

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

Having trouble accessing NSE Bhavcopy zip file in R due to a HTTP status of '403 Forbidden'

My current project involves automating the process of downloading a zip file in R. On the specific webpage I am working with, I can easily download the zip file by clicking on it or by right-clicking and saving the file. However, my challenge lies in down ...

The HTML content retrieved through an ajax service call may appear distorted momentarily until the JavaScript and CSS styles are fully applied

When making a service call using ajax and loading an HTML content on my page, the content includes text, external script calls, and CSS. However, upon loading, the HTML appears distorted for a few seconds before the JS and CSS are applied. Is there a sol ...

tips on sending multiple data- id in a modal window

Let's say I have multiple order IDs $order_id='12345566778'; $prod_id='126778899'; $sell_id='373462562363'; When I select a particular order ID, I want to pass it to a PHP variable located in the modal body of a popup. ...

Achieving a scrollable div with ng-repeat

I have implemented ng-repeat to showcase some messages, and I am attempting to create a scrollable "message_area" as the messages overflow naturally over time. However, my current code is not delivering the desired outcome. <div class="main_area"> ...

Solving the issue of overflowing in the animation on scroll library

I've recently started using a fantastic library called animation on scroll (aos) for my web development projects. This library offers stunning and visually appealing animations. However, I encountered an issue where it causes overflow problems in my H ...

Tips for sending variable from JavaScript to PHP Page through XMLHTTP

Make sure to review the description before flagging it as a duplicate. In my understanding, the method of transmitting data from JavaScript to PHP is through Ajax Call. This is the situation I am facing: With PHP, I bring forth an HTML page that cont ...

Place text within SVG in alignment

There seems to be an issue with aligning text in Adobe Illustrator when exporting graphics to SVG. When the text is initially exported, it is aligned to the center, but if you change the text using JavaScript from "Default text" to "New text", the alignmen ...

Add a border to the element if its height exceeds 300 pixels

My web page has a dynamic element with an unpredictable height. As more content is added, the element grows, but I have restricted it with a max-height: 300px;. However, I would like to add a hint to the user when the element reaches its maximum height by ...

Displaying the Polymer Paper spinner when the page is still loading

How can I make the polymer paper spinner display while the body tag is set to unresolved? I'm experiencing a brief blank screen before the page finishes loading. I'm feeling lost and unsure of how to begin. Check out the Polymer Project documen ...

Use jQuery to trigger a click event when an element is in focus, unless it was clicked to

I am currently developing a website using the MDL framework. One issue I encountered is that there is no default select form element provided. After some research, I found a solution by utilizing a menu component that displays when the input is clicked. Th ...

What Happens When You Click on a Link in Google News Using the Mobile Chrome Browser

When using the Chrome Browser on mobile to open a news link from Google News, a new tab is opened. To return to Google News, users can click on the white-highlighted "left arrow" below or find a small header with a "<" symbol above to navigate back. Ho ...

Tips for evenly distributing list elements in HTML without using whitespace

After reading the article on flexbox techniques without actually using flexbox, I attempted to implement "space-between" in my code: ul { margin: 0; padding: 0; text-align: justify; } ul:after { content: ""; display:inline-block; width:100%; ...

The color attribute in a Div container remains the same even when hovering over it

Hello everyone, I am new to stack overflow so please bear with me. I am currently working on this small webpage for my IT course and I have encountered a significant issue. .float1 { float:right; background-color:#A3635C; margin-top: 150px; ...

Tips for accessing basic information from these websites without encountering CORS issues

Having issues retrieving data from the following two sites: and Eurolottery. The CORS issue is causing the problem, and I was able to retrieve data using a Chrome CORS extension and the provided code below: var HttpClient = function() { this.get = fu ...

Is it possible for image.src to pose a security threat?

Here is the code snippet I am working with: var image = new Image(); image.src = "https://MyTrackingSite.com/?myTrackingParameter=whatever" I noticed that the image is not added to the DOM tree. Is it still rendered by the command "image.src"? Could this ...

Inline-block display causing divs to act unpredictably

I am working with a main div that contains three smaller divs inside. Each of these divs has been assigned a width of 30%, and they are all perfectly centered within the main div. To ensure that the three divs appear side by side, I used the display: inli ...

Tips for aligning spin.js spinner in the center of a bootstrap 3 modal?

I'm attempting to showcase and center the spin.js spinner within a Bootstrap 3 modal. Despite successful implementation in IE and FF using the code below, I am encountering issues in Chrome, Safari Desktop, Chrome IOS, Safari IOS. The problem appears ...

Why isn't the image adjusting its size to fit the container it's placed in? Am I missing something?

My issue involves getting an image to resize and stay within its designated div. However, the image continues to spill over onto the div below when I adjust the browser size or view it on my laptop. I have not set any fixed dimensions for the image. I am ...

Immersive Bootstrap Header Design

I've been attempting to achieve a full-screen background within the header element, but for some reason it's not displaying properly? Code header { position: relative; width: 100%; min-height: auto; text-align: center; color: #fff; ...

Using jQuery to add a class to an input option if its value exists in an array

Looking for a way to dynamically add a class to select option values by comparing them with an array received from an ajax call. HTML <select id="my_id"> <option value="1">1</option> <option value="2">2</option> ...