scrollable header within the confines of the container

I have been trying to find a solution for my scrolling issue, but I just can't seem to get it right. I want the content within a div to scroll inside its container without affecting the header. Here's the updated JSFiddle link with the jQuery code: updated JSFiddle.

HTML:

<div id="my_events" class="profilePopup">
    <div class="title_background">
        <h3>My Events</h3>
    </div>

            <div id="myEventsDetails_contaner">

                <div class="myEventsIcon">
                   <div class="eventDetails">
                   <a href="">
                   <img src=""width="70px">
                   <h5><span>12-02-2014</span></h5>
                   <h5>event</h5></a>
                </div>
              </div>

                <div class="myEventsIcon">
                   <div class="eventDetails">
                   <a href="">
                   <img src=""width="70px">
                   <h5><span>12-02-2014</span></h5>
                   <h5>event</h5></a>
                </div>
              </div>

                <div class="myEventsIcon">
                   <div class="eventDetails">
                   <a href="">
                   <img src=""width="70px">
                   <h5><span>12-02-2014</span></h5>
                   <h5>event</h5></a>
                </div>
              </div>
                 <div class="myEventsIcon">
                   <div class="eventDetails">
                   <a href="">
                   <img src=""width="70px">
                   <h5><span>12-02-2014</span></h5>
                   <h5>event</h5></a>
                </div>
              </div>

              <div class="myEventsIcon">
                   <div class="eventDetails">
                   <a href="">
                   <img src=""width="70px">
                   <h5><span>12-02-2014</span></h5>
                   <h5>event</h5></a>
                </div>
              </div>


    </div>
</div>

CSS:

#myEventsDetails_contaner{
    max-height: 100%;
}
.profilePopup{
    border: 1px solid black;
    background: #f8f8f8;
    z-index: 999;
    width: 400px;
    height: 200px;
    overflow:scroll;

}
.title_background{

    background: rgba(0,0,0,0.75);
    margin-bottom: 15px;
    padding:10px;
    position: relative;
}
.myEventsIcon{

    padding:10px;
    display: inline-block;
}

.eventDetails
{

    text-align: center;
}

.eventDetails h5 span{

    color:#ff1a00;
    display: block;
}

.eventDetails a{

    width:150px;
}

Answer №1

Move the title_background div outside of the profilePopup div and update the CSS for the title_background class to:

.title_background{   
    background: rgba(0,0,0,0.75);
    padding:10px;
    width: 382px;
}

Here is the updated code on Fiddle: http://jsfiddle.net/U7AVL/

My Edited Code

You can view the changes made on this new Fiddle link: http://jsfiddle.net/epLyC/

I believe this modification will be beneficial for your project.

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 is the best way to change the background color for my photo gallery?

I'm currently working on a project to create a unique photo gallery where each image has a different colored background. I have six images in total, but right now all of them have a pink background. I've attempted adding another .popup class in t ...

Getting elements in order with bootstrap

Can you help me align the "Format Example" string with the textual labels of the input fields without using static width in AngularJS with Bootstrap? The current alignment is right-justified but I would like it to be more dynamic as shown in the screenshot ...

Do not let CKEditor interact with widget content

Even though the HTML content within the aside tag is not editable, CKEditor still performs content filtering and removes tags while displaying hidden input fields. Here is the relevant HTML widget code: <aside class="widget widget-form" contenteditabl ...

Is it possible to use styled-components to specifically style a child class within a component?

Hey there, I'm currently working with a mui Badge component and am trying to customize the appearance of the small circle. This is what I have so far: const BadgeStyled = styled(Badge)` & > .muibadge-badge: { background-color: #d3d4d7; ...

Each div will display the same image twice when loading the image

I have a grid where images are dynamically loaded with a link to a lightbox. Currently, this is how I am achieving it: $(".selection_thumb").each( function(i) { $(this).append("<a data-lightbox='image-1' href='img/folder/folder/"+(++ ...

using JQuery, add a class on click event or on page load

Solved It! After encountering a problem created by some sloppy moves on my part, I managed to solve it. However, another issue arose: adding the class current to li with data-tab="tab-1 upon page load. $('ul.tabs li').click(function(){ ...

Tips for creating a concise summary of written content

I am interested in creating an AI-powered summary generator for text input within a textarea element. Below is the HTML code snippet I have been working with: <textarea id="summary">Enter your text here</textarea> If you hav ...

Lean/Tilt just the lower portion of the division

I have been experimenting with adding a unique slant to the bottom of a div. Progress has been made, as shown in the example below where I successfully applied the slant to some elements on the page. Currently, the slant is visible on both the top and bot ...

Struggling with uploading files in AngularJS?

Below is the code snippet from my controller file where I aim to retrieve the values of various input elements (name, price, date, image) and store them in an array of objects... $scope.addBook = function(name, price, date, image) { name = $scope ...

The HTML is not rendering as planned

I have 2 files, test.html <!DOCTYPE html> <head> <title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="./test/jquery.min.js"></script> </head> <body> ...

The blur function in jQuery is not functioning as expected

I'm facing an issue where only the first of my 3 .blur's is working. Here is the jQuery code snippet: <script type='text/javascript'> $(document).ready(function() { $("#user_name").blur(function() { if ($( ...

The descendant selector in CSS fails to apply changes to the element

I am struggling to modify the border of a specific descendant element and so far I have not been successful. Despite using the correct descendant selector in the HTML below, the style change is not taking effect. If anyone has any insights on what could be ...

JS How can I generate individual buttons in a loop that trigger separate actions?

Currently, I am working with loops in jQuery to create a series of boxes that contain specific values. The problem arises when I try to assign actions to each box based on the values from an array. For example, I want each box to trigger a different alert ...

Is there a way for me to expand the dropdown menu?

My current dropdown looks like this. I'd like the dropdown menu to span across the screen, something like this: To create my dropdown, I am using https://github.com/angular-ui/ui-select2. AngularJS JQuery Select2 I'm not sure if there is an ...

Discover the hexadecimal color code generated from an rgba color

Do you know of a service that can determine the final hexadecimal value of an rgba color? For instance, if my body background-color is set to #FF0000 and my header is positioned over it with a background-color of rgba(0,0,0,.7), how can I find out what the ...

Do not ask for confirmation when reloading the page with onbeforeunload

I am setting up an event listener for the onbeforeunload attribute to show a confirmation message when a user attempts to exit the page. The issue is that I do not want this confirmation message to appear when the user tries to refresh the page. Is there ...

Displaying an HTML file in a Node and Express application using JavaScript File handling

Starting my first Node, Express & Angular project has been a bit tricky due to issues with the asset pipeline. I'm not entirely sure if it's related to my folder structure, which I tried setting up based on online tutorials but am open to suggest ...

Issue with VueJS where the datalist input does not reset the value

I am currently working on a Vue component that scans QR codes and adds information to a database upon successful scanning. The scanning process works perfectly fine. However, after successfully sending the data, I need to clear the input field in my datali ...

Flexbox CSS Card Layout Behavior

Looking to achieve a specific design effect without relying on Semantic UI? Check out the codepen link here: https://codepen.io/anon/pen/YxBOax <div class="ui container"> <div class="ui four cards stackable"> <div class="teal card"> ...

Automatic Update Division in Jade Template (Node.js/Express)

In my development project using Node.js, Express, Jade, and Redis, I have successfully created an app that pulls telnet stream data from reversebeacon.net. This data is then cross-referenced with Redis databases containing amateur radio club member informa ...