css customized vertical scrollbar for a static division panel

I have the following HTML content and I need a fixed sidebar with 100% height. The vertical scrollbar should appear when content is added in mainContent or Content.

<div class="mainContainer">
  <h2>Title</h2>
  <div class="Content">
      <div class="panel panel-success">
          <div class="panel-heading">
              My Panel-1
          </div>
          <div class="panel-body">
              blah... ..blah blah blah... ..blah blah blah... ..blah blah blah...
              blah blah blah... ..blah blah blah... ..blah blah blah... ..blah blah blah
              blah blah blah... ..blah blah blah.
              </div>
      </div>
      <div class="panel panel-success">
          <div class="panel-heading">
              My Panel-2
          </div>
          <div class="panel-body">
              blah... ..blah blah blah... ..blah blah blah... ..blah blah blah...
              blah blah blah... ..blah blah blah.
            </div>
        </div>
    </div>
</div>

This is my CSS:

.mainContainer
{
    float:right;
    height: 100%;
    width:350px; 
    padding:3px; 
    background:#f00;
    overflow-y:auto;
}
.Content
{ 
    background:#fff;
}

Answer №1

To enhance your style, make the following adjustments:

Eliminate

overflow-y: hidden

and incorporate

overflow-y: scroll
position:fixed;

By implementing these changes, you can see improvement in your design. Feel free to test it out on this example jsfiddle.net/467fz6rp/1

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

"Trouble with jQuery: Selecting an image to change isn't

Can someone help me figure out why my simple image change on a dropdown isn't working correctly? You can find the code on this Jsfiddle. Thank you for any assistance! $("#display_avatar").change(function(){ $("img[name=preview]").attr("src", $( ...

Personalizing the collapse animation in bootstrap 4

When utilizing Bootstrap 4, the class .collapsing is used to animate the width/height of an .collapse-element while opening/closing it. However, the actual transition occurs by adding the width/height as an inline style to the element and toggling the clas ...

A guide on transforming HTML into a variable using JavaScript

Having trouble converting HTML to a JavaScript variable. This is my HTML code: <div onclick="openfullanswer('2','Discription part','This is the code part');"> I want to create this HTML code dynamically, but I&apo ...

Shifting hues of dots within a grid according to the passing of time

As a newcomer to the world of coding, I have conceptualized an idea for a visually appealing clock. My goal is to visually represent the passage of time throughout the day. To achieve this, I have devised a grid system where each dot on the grid represents ...

The input field within the mat-form has been styled to match the background of the page using CSS

I am currently facing an issue with the code below: Html: <form fxLayout="column" fxLayoutAlign="center center" [formGroup]="deleteForm" (ngSubmit)="onSubmitForm()"> <mat-form-field color="accent" appearance="outline"> <input ...

The HTML code is failing to apply the style to all rows except for the first one in the sql query result

When retrieving all the rows from a SQL database with a query and using a loop to iterate through them, I encountered an issue where only the first row was receiving the specified CSS style. The remaining rows were not applying the style as expected. < ...

Tips for customizing the appearance of the React Native side menu

After successfully implementing a side menu using react native, I am now looking to style the image to match the design shown in the links below: Check out the application I developed I want it to look like this Is styling the key to achieving this desi ...

Using the last child as a parent element in Selenium with JavaScript

I am trying to access the input element of the last child in this code snippet. Specifically, I want to retrieve the text Text Reply - Delete. <div class="priority-intent-div"> <div class="row add-priority-intent-div"> ...

The impressive wipe effect in velocity.js using css and jquery

I am looking to achieve a slide effect similar to Powerpoint's wipe using css, jquery, or velocity.js. Here is a video showing the desired effect: https://www.youtube.com/watch?v=VSBB0wfccws I attempted to use css3 masking (svg/gradient) but was uns ...

Is it possible to adjust the viewport to a size larger than 1024?

This site we're examining is not responsive and has a width of about 1230 pixels. When viewed on mobile devices, some content is cut off from the right side due to compression, resulting in approximately a 10% loss. The issue becomes more noticeable ...

Tips for aligning icons and text correctly within a table

I can't seem to align the icon vertically with the text. Currently, the image icon is positioned in the middle of the <td> tag, but I want it at the top, as shown in the jsfiddle: http://jsfiddle.net/TheAmazingKnight/N6fLp/ To help visualize th ...

Excessive HTML and CSS overflow stretching beyond the boundaries of the page on the right

It seems like the issue lies with div.ü and div.yayın, as they are causing overflow on the right side of the page. When these elements are removed, the overflow issue goes away. Are there different positioning codes that can be used to prevent this? d ...

Is Jquery not tallying up the numbers accurately?

Looking to secure a ticket with a complimentary offer? Here are the guidelines: A single individual can purchase 1 or more tickets, but the maximum is 4 An offer of at least 1 euro can be made for tickets, with no upper limit. For instance, if 4 tickets ...

Tips for adjusting the CSS styles within a jQuery plugin

I need some help with styling the form on my test page located at While using FireBug, I noticed a lot of padding space surrounding the tabs within this div: <div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> How can I redu ...

Looking to display a different HTML document in a div - any suggestions?

I am in the process of creating a website that will feature four tiles on the front page. Once a tile is clicked, I would like the content to appear in a window that has a slight transparency to allow the main page to show through. So far, I have managed ...

Include a triangle shape at the top of a div container that has a background image using CSS

Struggling to add a point or triangle shape to my div with a background image, finding it difficult to create enough open space. This is the desired outcome: https://i.sstatic.net/LZVaF.png This is what I have implemented so far: <div class="bg"> ...

Utilizing a custom font to emphasize the extended phrase in the following sentence

I've been trying to use word-wrap to break long words into the next line, but unfortunately it's not working as expected. You can view my JsFiddle code for reference. The divs on my page are generated dynamically, and here is an overview of what ...

Simple CSS3 Features for Seamless Browser Compatibility

Is there a more efficient way to add box-shadow to an HTML element? Currently, I have to include the following code: box-shadow: 2px 2px 3px #969696;<br> -moz-box-shadow: 2px 2px 3px #969696;<br> -webkit-box-shadow: 2px 2px 3px #969696; filte ...

Styling: How can I create indentation for a specific text area while leaving another unaffected?

I am attempting to format this complete form with an indentation: <%= form_for([micropost, micropost.comments.build], :html => { :id => "blah_form" }) do |f| %> <div class="field"> <p2>Who are you?</p2> ...

two divs side by side with adjustable sizes

Is there a way to achieve a typical forum post layout with user info on the left and the post itself using CSS? I tried wrapping two divs around another div and using float, but encountered an issue where the floated div remains on the left instead of next ...