Column causing div to not scroll

I've set up a bootply template where I have panels in a column on the right side. My goal is to make these panels scroll within the column without affecting the header or footer. However, for some reason, the 'overflow-y: scroll' property doesn't seem to be working!

Take a look at my code:

html,body,.container {
    height:calc(100% - 17px);
}
.container {
    display:table;
    width: 100%;
    margin-top: -50px;
    padding: 0px 0 0 0; /*set left/right padding according to needs*/
    box-sizing: border-box;
}

.row {
    height: 100%;
    display: table-row;
}

.col-md-3 {   
    background: pink;
}
.col-md-9 {
    background: yellow;  
}

.row .no-float {
  display: table-cell;
  float: none;
}
header, footer {
            text-align: center;
            padding-top: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid lightgrey;
            background: white;
        }

        footer {
            border-top: 1px solid lightgrey;
            position: absolute;
            bottom: 0;
            width: 100%;
        }
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    &...

</footer> 
        </div>
    </div>
</div>

Answer №1

To enable scrolling for #eventsContainer, you should set the height using CSS's calc() function. Here's an example:

#eventsContainer {
  height: calc(100% - 122px); /* Total Height - Height of (header + footer) */
}

You can see this in action with the snippet below:

#eventsContainer {
  height: calc(100% - 122px);
}

html,body,.container {
    height:calc(100% - 17px);
}
.container {
    display:table;
    width: 100%;
    margin-top: -50px;
    padding: 0px 0 0 0; /*set left/right padding according to needs*/
    box-sizing: border-box;
}

.row {
    height: 100%;
    display: table-row;
}

.col-md-3 {   
    background: pink;
}
.col-md-9 {
    background: yellow;  
}

.row .no-float {
  display: table-cell;
  float: none;
}
header, footer {
    text-align: center;
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid lightgrey;
    background: white;
}

footer {
    border-top: 1px solid lightgrey;
    position: absolute;
    bottom: 0;
    width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<!-- Your navigation bar HTML code and content here -->

<div class="container">
    <div class="row">
        <div class="col-md-6 no-float">Navigation</div>
        <div class="col-sm-6 no-float" style="padding-left: 0px; padding-right: 0px;">
            <!-- Your header and events container HTML code here -->
        </div>
    </div>
</div>

I hope this solution works well for your layout!

Answer №2

The issue arises when the content surpasses the container's boundaries in an overflow situation. In this scenario, the #eventsContainer lacks a specified height, causing the content to extend beyond the limits due to HTML's natural expansion vertically.

To enable scrolling functionality, you must assign a specific height to your #eventsContainer.

Considering that you likely prefer a dynamically adjusting height opposed to a static value like '300px', I have crafted a jsfiddle showcasing absolute positioning techniques for creating a full-screen layout without protruding outside.

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

Is it possible to modify the background-image using Typescript within an Angular project?

I have been struggling to change the background image in my Angular project using Typescript. I attempted to make the change directly in my HTML file because I am unsure how to do it in the CSS. Here is the line of code in my HTML file: <div style="ba ...

"Implementing a function where two different elements can change the text of a button

I have created a custom FAQ script using dl, dt, and dd elements: $('.faqs dd').hide(); // Hide all DDs inside the .faqs container $('.faqs dt').hover(function(){ $(this).addClass('hover' , 'slow')},function(){ ...

Bars of varying heights (Google Chart)

I have incorporated a Google chart within a mat-grid-tile. In this setup, one column displays a value of 50, while the other showcases a value of 30. These particular values are sourced from myService and are accurate. Although when I hover over the bars i ...

Error encountered: Failure to construct URL for endpoint 'Bookdetails'. Have you overlooked supplying values for the parameter 'book_id'?

I have been troubleshooting this issue and reviewed similar threads, yet despite verifying all options, the problem persists. My code includes: application.py @app.route("/Booksearch/<int:book_id>", methods=["GET", "POST"]) def Bookdetails(book_id ...

The alignment of two elements is off in mobile display

Why aren't my two divs centered in mobile view? I am using Vuetify CSS flex helper justify-center to try and achieve it, but it doesn't seem to be working. Even when I use justify-sm-center, it still doesn't work. What am I missing? <v-co ...

Design a clickable div element embedded within an interactive article using HTML5

Currently, I am facing an issue with placing clickable div elements inside an article tag in HTML5. The problem is that when I try to click the divs, it registers as a click on the article itself. Below is an example of my code: HTML: <article id=&apo ...

Spacing between posts using CSS and jQuery

Currently, my code is creating a random number of new articles within the body of my webpage. I have successfully implemented different colors for each article, but I am encountering an issue with padding. Being new to web development, I am attempting to s ...

Make sure to employ Bootstrap's justify-content-between and stack-to-horizontal col correctly

I am currently working on a responsive form that contains 1 label, 1 input field, and 5 buttons. Both the buttons and the input field are located under col-8. The positioning I aim for the buttons is as follows: They should start below and align with ...

Generate responsive elements using Bootstrap dynamically

I'm having success dynamically generating bootstrap elements in my project, except for creating a drop-down menu. ColdFusion is the language I am using to implement these div elements: <div class="panel panel-primary"><div class="panel-head ...

Combining verification with Recaptcha (or necessary information)

I'm looking to customize a form below by setting certain fields as required based on different conditions. I would like the Name and Email fields to be mandatory, with a popup alert if they are left empty: Name Email If the "Phone" checkbox i ...

What is the best way to access a model attribute in every template?

My goal is to showcase the name of my model team in the website header. The Team model has a attribute named "name": class Team(models.Model): name = models.CharField(max_length=50, null=True, blank=True) In my template language, I am trying to disp ...

Ensuring that the empty bubble remains undisturbed, here's a guide on effectively implementing the if

I need assistance with adding an "if condition" to my text field. The condition should prevent the empty bubble from appearing when the send button is clicked. function verifyInput(){ var currentText = document.getElementById("demo").innerHTML; var x ...

Generate an li element that is interactive, containing both text and a span element

I am dealing with a JSON array that looks like this: var teamDetails=[ { "pType" : "Search Engines", "count" : 5}, { "pType" : "Content Server", "count" : 1}, { "pType" : "Search Engines", "count" : 1}, { "pType" : "Business", "count" : 1,}, { "pTyp ...

The transparent image is causing the menu item to be hidden underneath it because of z-index complications

Could you please review this jsfillde? <nav role="navigation" class="nav-main"> <ul class="nav nav-pills" id="menu-primary-navigation"> <li class="active menu-home"><a href="/">Home</a></li> <li ...

What is the best way to ensure that text only displays up to five lines and fully collapses using CSS or javascript/jquery?

Hello everyone, I have come across an issue. English is not my strong suit, but I will do my best to explain it thoroughly. The problem at hand is a design requirement in the draft that specifies showing up to five lines of text. If the text exceeds this ...

Creating a div larger in size than the wrapper

Would it be feasible to have a container with a width of 1000px;, while simultaneously having a DIV inside the container that has a width of 100%? Is that achievable in any way? Here is a snippet of my code: <div class="block1"> <img src="i ...

The page fades in as soon as it is loaded thanks to the "

I am interested in creating a unique effect where different classes fade in on page load. Check out this webpage for reference. The linked page showcases squares in various shades of grey and color, with the desire to have them fade in at different inter ...

Angular Bootstrap Datepicker provides us with a date object, but I need it in the Date format

My desired date format is "Wed Aug 07 2019 16:42:07 GMT+0530 (India Standard Time)", but instead I am receiving { year: 1789, month: 7, day: 14 } from ngbDatepicker. Any assistance on resolving this issue would be greatly appreciated. ...

generate a customized synopsis for users without storing any data in the database

In order to provide a summary of the user's choices without saving them to the database, I want to display it in a modal that has already been created. Despite finding some sources online, none of them have worked for me so far. Below is my HTML: &l ...

"Ascend beyond the constraints of fixed measurements with dynamic

My JQuery image fader has a width of 100% and height set to auto. I'm thrilled that it works perfectly on the iPhone as well. Now, I am facing a challenge while trying to make content "float" after my JQuery slider. The problem arises because I use ...