Unable to create scrolling functionality for the div in Bootstrap

I'm working with a code that includes a text input for users to enter information, along with a panel above the text input that displays what the user has typed. I want the height of the panel above the text field to be set so that it becomes scrollable when it overflows.

<div class="row-fluid" style="max-height:10;overflow-y: scroll;">
  <div class="panel-body" style="max-height:10;overflow-y: scroll;">
    {% for message in messages %} {% module Template("message.html", message=message) %} {% end %}
  </div>
</div>

<div class="row-fluid">
    <form action="/a/message/new" method="post" id="messageform" class="span12">
      <table>
          <tr>
              <td>
                  <input name="body" id="message" style="width:500px">
              </td>
              <td style="padding-left:5px">
                  <input type="submit" value="{{ _(" Post ") }}">
                  <input type="hidden" name="next" value="{{ request.path }}">{% module xsrf_form_html() %}</td>
          </tr>
      </table>
    </form>
</div>

Additionally, I want the section above to remain fixed and not expand into the below section.

<div class="row-fluid">
  <div class="span4">
     testet seetsetsetset
  </div>
  <div class="span4">
    testsetstse estsetset
  </div>
  <div class="span4">
   setsetetsets setsetset
  </div>
</div>

The Bootstrap version used in this tutorial can be found at the following link:

I have also applied the following CSS to format the user input and reply results. If there are any suggestions on how to achieve this in a more Bootstrap-friendly way, I would appreciate some guidance:

body {
  background: white;
  margin: 10px;
}

body,
input {
  font-family: sans-serif;
  font-size: 10pt;
  color: black;
}

table {
  border-collapse: collapse;
  border: 0;
}

td {
  border: 0;
  padding: 0;
}

#body {
  position: absolute;
  bottom: 10px;
  center: 10px;
}

#input {
  margin-top: 0.5em;
}

#inbox .message {
  padding-top: 0.25em;
}

#nav {
  float: right;
  z-index: 99;
}

Answer №1

Ensure the height value you assign is a measurable unit such as px, em, or %. It's only necessary to specify it for one of the containers. You can also opt to hide the scrollbar when it's not needed by utilizing overflow-y set to auto instead of scroll.

You have some erroneous CSS code in there. The property center does not exist in CSS and has been commented out in the example I provided.

The modification made was switching:

<div class="row-fluid" style="max-height:10;overflow-y: scroll;">
  <div class="panel-body" style="max-height:10;overflow-y: scroll;">

to

<div class="row-fluid" style="max-height:50px;overflow-y: auto;">
    <div class="panel-body">

Here is the complete code snippet:

body {
    background: white;
    margin: 10px;
}

body, input {
    font-family: sans-serif;
    font-size: 10pt;
    color: black;
}

table {
    border-collapse: collapse;
    border: 0;
}

td {
    border: 0;
    padding: 0;
}

#body {
    position: absolute;
    bottom: 10px;
/*    center: 10px;  // This is invalid */
}

#input {
    margin-top: 0.5em;
}

#inbox .message {
    padding-top: 0.25em;
}

#nav {
    float: right;
    z-index: 99;
}
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="http://getbootstrap.com/dist/css/bootstrap-theme.min.css" rel="stylesheet"/>
<script src="http://getbootstrap.com/assets/js/ie-emulation-modes-warning.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<div class="row-fluid" style="max-height:50px;overflow-y: auto;">
    <div class="panel-body">
        {% for message in messages %} {% module Template("message.html", message=message) %} {% end %}
    </div>
</div>
<div class="row-fluid">
    <form action="/a/message/new" method="post" id="messageform" class="span12">
        <table>
            <tr>
                <td>
                    <input name="body" id="message" style="width:500px">
                </td>
                <td style="padding-left:5px">
                    <input type="submit" value="{{ _(" Post ") }}" />
                    <input type="hidden" name="next" value="{{ request.path }}" />{% module xsrf_form_html() %}
                </td>
            </tr>
        </table>
    </form>
</div>
<div class="row-fluid">
    <div class="span4">
        testet seetsetsetset
    </div>
    <div class="span4">
        testsetstse estsetset
    </div>
    <div class="span4">
        setsetetsets setsetset
    </div>
</div>

Note: For a clearer view of the changes, refer to this Bootply demo link: http://www.bootply.com/1LGjrUomIl

Answer №2

max-height:10;

The value provided is invalid; it must be followed by "px", "em", "cm" or "%". Try adding one of those units to see if it resolves the issue.

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

Load images in advance for hover effects on active selectors within the specified CSS file paths

Currently, I have opted not to utilize css sprites. While I acknowledge that it is the most efficient solution, time constraints prevent me from implementing it at this moment. I am seeking a method to preload all images for hover and active selectors. ...

Sorting elements in order based on their attribute values using jQuery

Exploring the use of the data attribute with jQuery for the first time, I am attempting to reorder an element based on its data-order attribute. I am struggling to retrieve the correct value of the data-order attribute as it keeps returning 'undefine ...

Issue with loading Bootstrap modal in KnockoutJS

Currently, I am working on a project to develop a CRUD system using knockoutJS and fetching data through an AJAX call. While I am still in the process of implementing the add and delete functionalities, I am facing issues with my modal. The modal form does ...

The importance of blending classes versus isolating classes in CSS selectors

Could somebody please direct me to the CSS hierarchy rules concerning "concatenated classes" versus "separated classes"? Furthermore, what are the correct terms for "concatenated classes" versus "separated classes" (I suspect that is why the documentation ...

What is the best way to encode a GLTF file without compromising the encoding of other meshes and textures?

Currently, I am working on a fascinating web AR app that enables users to don GLTF head models. (You can check it out at ) To ensure optimal lighting of the GLTF model, I have implemented renderer.outputEncoding = THREE.sRGBEncoding, which has been very ef ...

The HTML input element does not comply with the specified pattern

My current struggle lies in validating the input field for a "Phone Number". Despite creating a regex pattern that demands 10 numbers, I still encounter the error message: "Please match the requested format". I am puzzled as to why this is happening, even ...

Why is it proving difficult to eliminate margin and padding from the top of the page?

Struggling to remove padding or margin from the top, I attempted to adjust the main container settings: margin-top:0px !important; padding-top:0px !important; Unfortunately, this did not have the desired effect. The code is too lengthy to include in thi ...

Adjusting Timeout for Specific HTTP Endpoint in NestJS

I recently delved into learning NestJS and I'm curious about how to adjust the response timeout for specific endpoints. One way is to set it on a server level like this: const server = await app.listen(...); server.setTimeout(1800000) Alternativ ...

Toggle the visibility of a component in React by managing its state

Currently, I am faced with the challenge of toggling the visibility of a component based on a state value: import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; import Button from ' ...

The ng-submit function in AngularJS is causing some issues and not functioning properly

In my HTML view, I have an ng-template which contains a form. I am trying to submit form data using ng-submit, but when I click on the submit button, nothing happens. However, other data bindings are working fine with text fields in the form, using ng-mo ...

Passing variables from ExpressJS to JavaScript can be a seamless process

I am struggling with this issue; I am utilizing NodeJS to retrieve a JSON and I must transfer the variable to my page for use by JavaScript. app.get('/test', function(req, res) { res.render('testPage', { myVar: 'My Dat ...

Mobile media queries are ineffective despite implementing the viewport meta tag

I am facing an issue that even though I have tried various solutions, my media queries are not working on mobile devices after adding the viewport meta tag. Can anyone provide insight into why this might be happening? Update: Upon further investigation, I ...

Differences between using Constructor(props) and super(props) versus simply using constructor() and super() in React Development

Although this question has been asked numerous times, it still remains unclear to me. Many have simply stated: Pass props to constructor if you want to access this.props there Here is another example of the answer The official documentation states tha ...

Can a javascript variable be integrated into JRoute() function?

function getProduct(category) { document.star.action = '<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='+ category) ?>'; document.getElementById('star').submit( ...

Is it possible to transfer the style object from PaperProps to makeStyles in Material UI?

I am working with a Material UI Menu component and attempting to customize its border. Currently, I am only able to achieve this customization by using PaperProps inline on the Menu element. However, I already have a makeStyles object defined. Is there a ...

Creating an Angular application within the success callback of a jQuery Ajax request

Using a jQuery ajax request, the HTML of one of several independent angular apps is loaded and injected into the DOM. Here is a simplified version of the code: $.ajax({ 'url': 'url-to-random-angular-app.html', 'success': ...

The Ajax response is not providing the expected HTML object in jQuery

When converting HTML data from a partial view to $(data), it's not returning the jQuery object I expected: console.log($(data)) -> [#document] Instead, it returns this: console.log($(data)) -> [#text, <meta charset=​"utf-8">​, #text ...

Ways to update a prop and reset it to its original state using React Hooks

My goal is to take a string prop text, trim it, and then pass it to the state of a component. I used to achieve this using the componentDidMount function in the past. However, now I am trying to use the useEffect() hook but encountering an error: "Cannot ...

Transfer information from an Express route to a function exported from a Node module

I'm new to using node.js and I've been told that I need to use middleware, but I'm having trouble understanding its purpose and the proper way to implement it. I have data that is being sent from my view to an express route. ROUTE - route.j ...

Revolutionizing the small screen design with a dynamic Bootstrap Responsive Layout that seamlessly adjusts to different screen sizes

In the beginning, I constructed a footer using HTML, CSS, and JS. Eventually, I stumbled upon Bootstrap and decided to recreate the footer using Bootstrap, following a mobile-first design approach for screens smaller than 576px. I had previously designed ...