Tips for ensuring the middle row remains sandwiched between the header and footer rows in Bootstrap

After adding styles for img with max-height:100% and max-width:100%, the display looked fine with just images. However, upon further inspection, I noticed that if the middle row (which can contain one or two columns side by side) has multiple images or an image with text around it, the layout breaks at larger resolutions.

The issue arises because this page displays user-created content on large televisions and monitors. At that point, the middle row pushes the footer row out of view and the content in the middle gets stretched downwards.

I'm not sure if I should make changes to the middle row (or the div inside with the columns for images/text) or try something different.

My goal is to ensure that whether it's a single large image, multiple images, text with an image, or any other combination, everything fits inside the top and bottom rows at all times. I don't mind if it causes the columns to shift more to the left or right, respectively.

Here's the fiddle: https://jsfiddle.net/vbuf0gwL/62/

When you resize the result to around 1457x781, you can clearly see the issue, especially on large displays.

Again, the top and bottom rows should always be visible while the middle content scales accordingly.

img {
  max-width: 100%;
  max-height: 90vh;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

.modal-lg {
  max-width: 80% !important;
}

.my-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.my-container>.top [class^="col-"],
.my-container>.bottom [class^="col-"] {
  background-color: #929292;
  color: white;
  text-align: center;
}

.my-container>.middle {
  flex-grow: 1;
  padding: 30px;
  background-size: cover;
}

.my-container>.middle>* {}

#clock {
  /*background-color:#333;*/
  font-family: sans-serif;
  font-size: 40px;
  text-shadow: 0px 0px 1px #fff;
  color: #fff;
}

#clock span {
  color: #fff;
  font-size: 40px;
  position: relative;
}

#date {
  margin-top: -10px;
  letter-spacing: 3px;
  font-size: 20px;
  font-family: arial, sans-serif;
  color: #fff;
}

.buttonContainer {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
<html>

<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7017191a171f30415e495e46">[email protected]</a>/css/gijgo.min.css" rel="stylesheet" type="text/css" />
  <link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="src/ytv.css" type="text/css" rel="stylesheet" />

  <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  <script src="https://npmcdn.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="463223322e2334067768746872">[email protected]</a>/dist/js/tether.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
  <script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a4d43404d456a1b0413041c">[email protected]</a>/js/gijgo.min.js" type="text/javascript"></script>
  <script type='text/javascript' src='//cdn.jsdelivr.net/jquery.marquee/1.4.0/jquery.marquee.min.js'></script>


</head>

<body>
  <div class="container-fluid my-container">
    <div class="row">
      <div class="col-lg-12" style="background-color:black">
        <p style="color:white">
          test
        </p>
      </div>
    </div>

    <div class="row middle" style="flex:1; ">
      <div class="col-lg-6 leftFifty" id="leftFifty">
        <div class="leftContent" style="background-color: white; border: dotted 1px black; ">
          <p>TEST</p>
          <img src="https://via.placeholder.com/1024x942" />
          <!-- This is the div that is clicked in to select an image -->
        </div>
      </div>
      <div class="col-lg-6 rightFifty" id="rightFifty">
        <div class="rightContent" style="background-color: white; border: dotted 1px black; ">
          <p>TEST</p>
          <img src="https://via.placeholder.com/1024x942" />
          <!-- This is the div that is clicked in to select an image -->
        </div>
      </div>
    </div>

    <div class="row ">
      <div class="col-lg-12" style="background-color:black">
        <p style="color:white">
          test
        </p>
      </div>
    </div>
  </div>
</body>

</html>

Answer №1

Make sure the header and footer are set to position: fixed; and have the top and bottom properties both set to 0.

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

What methods can be used to secure Next.js API routes and prevent them from being directly accessed through the URL

I am seeking a solution for concealing the response data of next.js API routes when accessed through URL. I need to protect certain sensitive information from direct access by users. ...

Resizing the container div to perfectly fit the displayed React component

Is there a way to render a component with its style and position defined by specific cases without having to create a container that takes up the entire body? I want the styles of the container to match those of the component, without the need for the cont ...

Retrieve the value of an AngularJS expression and display it in a window alert using AngularJS

Hey there, I am in the process of trying to display the value of an expression using AngularJs As a beginner in angular, I am working on figuring out how to retrieve the value of the expression either with an alert or in the console. I'm utilizing A ...

What's the best way to make div columns appear closer together when floating?

Check out My CodePen: http://example.com/codepen Hello there, today I am working on a 6-column layout with 3 columns in each row. The 3rd column is quite long and resembles a sidebar. According to the design, columns 4 and 5 should be positioned close to ...

Splitting columns evenly in a table with a width of 100%

Welcome to my first query on this platform. Despite my efforts to search for a solution, I couldn't find an explanation as to why my code isn't functioning correctly in Internet Explorer (10+). I have created three divs displayed as cells, each ...

Troubleshooting problems with AJAX function in the .each() loop

My webpage showcases a grid layout with 16 blocks arranged in 4 columns and 4 rows. As you scroll to the bottom of the page, an AJAX function dynamically loads another set of 16 blocks each time. To enhance user experience, I wanted to implement a smooth ...

What is the most effective way to construct this array?

I have an array of objects that contain multiple properties: [ { a: 3, b: 2, c: 5, d: 6, e: 8 }, { a: 1, b: 5, c: 3, d: 1, e: 2 } ] My goal is to extract only the values of specific properties and create a new array without the objects. For example, ...

What is the process for cancelling an interval when it is disabled in my configuration file?

To automate a bot, I want it to stop running an interval if the configuration file specifies "off" and continue running if it says "on". I attempted this: Using discord.js: config.Interval = setInterval(() => { WallCheck.send(WallCheckemb ...

There was an error in the syntax: JSON parsing error, an unrecognized token '<'

Having trouble with a syntax error: JSON parse error due to an unrecognized token '<'. One page is functioning properly with the same code, while another is displaying this error. I am unable to identify my mistake. Front-end code: const getd ...

Executing a TypeScript function directly in HTML without the need for a click event

I understand how to trigger a TypeScript function when clicking a button, but how can I initiate a function without relying on a specific event? My goal is to call a function once an array named chartData has been populated. Here is the code snippet I have ...

Issue with React ChartJS rendering – Title not visibleWhen using React Chart

I'm currently using react chart js for displaying a doughnut in my component. "chart.js": "^3.7.1", "react-chartjs-2": "^4.1.0", However, I'm facing an issue where the title is not being displayed: const d ...

Is Node.js compatible with Mysql Schema?

Currently working on a web service using Node.js, I've decided to switch from MongoDB to MySQL. With MongoDB, I could easily create a schema using Mongoose: var mongoose = require('mongoose'); var Schema = mongoose.Schema; mongoose.connect ...

The table is not displaying the CSS class as intended

I need to modify the behavior of a table so that upon clicking on a value, a specific class is set and the user is redirected to a particular page. The structure of the table is as follows: <?php // Determine the file name based on content type if( ...

Retrieving Results from Sequenced Promises

I am facing an issue with returning data from a chained promise. In the following scenario, how can this be achieved? Here is some pseudocode: mark = function(){ return promiseA .then(function(data){ .....}) .then(function(data){return ne ...

Using Javascript to Retrieve Icecast Metadata

I am currently developing a web radio application that utilizes AngularJS and Laravel 5 to read Icecast streams. Currently, I have implemented loading the stream into an html5 audio element which is working well. However, I am facing an issue where the vie ...

Issue with form not capturing information from dynamically generated fields

I'm working on creating a dynamic form for user input of on/off instructions in pairings. The HTML code defaults with one pair, and the user can add additional pairs using a button. However, upon form submission, Angular is only reading the values fro ...

What are the steps for executing an API and entering data into it?

I have developed an API using NodeJS, ExpressJS and MongoDB to filter and sort school data based on location and fees. The main code snippet looks like this: const express = require('express'); const bodyparser = require('body-parser') ...

Attempting to streamline this function in order to avoid running it nine separate times

I have created a day scheduler and successfully saved data in local storage for one hour field. However, I am looking for a way to streamline this function so that I can use it across all 8-hour fields without duplicating the code. Can someone provide me w ...

Adjust the color of static hyperlinks based on the background color

Is there a way to dynamically change the color of my fixed side links based on the background color when scrolling? I attempted to use CSS mixed-blend-mode: difference, but it does not provide the level of control I need. Therefore, I am looking to achieve ...

Finding the next div by its ID using jQuery

Currently, the jQuery code provided only allows navigation from the Sport section to the Entertainment section. Is there a way to create a script that allows navigation between any div sections with just one piece of code? <div id="topBar"> &l ...