Tips on increasing the height of an element that is overflowing

When populating my timeline component with dynamically mapped data from an array, I encountered an issue where if I added more data causing the maximum height to be reached, the overflow-y element didn't display all content. Despite trying various solutions, I'm still unable to achieve the desired result. You can view my code on CodeSandbox.

SCSS File:

// Your SCSS styles go here...
    

Component Structure:

<>
     <section>
     <h1>Education</h1>
     <div id="timeline" className='timelineWrapper'>
         {/* Data mapping logic */}
     </div>
     </section>
     </>

The component should have an internal scroll height set to 30vh (30%) and a maximum height of 80vh (80%):

https://i.stack.imgur.com/zNqqn.png

I'm looking to make the green bar displayed in the image proportionate to the number of items added to the timeline. Can anyone provide assistance with achieving this effect within the #timeline container?

&:before {
            content:"";
            width: 5px;
            height: 100%;
            background: #26C17E;
            left: 50%;
            top: 0;
            position: absolute; 
    

Answer №1

After incorporating a div with the class timelineContainer into App.js and making some adjustments to timeline.scss, I believe I have achieved what you were looking for. You can view the live example on CodeSandbox and see the updated code below:

App.js:

import "./styles.css";

export default function App(props) {
  const { data } = props;
  return (
    <section>
      <h1>Education</h1>
      <div className="timelineContainer">
        <div id="timeline" className="timelineWrapper">
          {data.map((info, index) => (
            <div className="timeline-item" key={index}>
              <span className="timeline-icon">
                <span>&nbsp;&nbsp;</span>
                <span className="year">{info.date}</span>
              </span>
              <div className="timeline-content">
                <h2>{info.title}</h2>
                <p>{info.text}</p>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

Timeline.scss:

// Mixins
@import "mixins";

// Timeline
// $timeline-color: #ee4d4d;
 

.timelineContainer{
    overflow-y: auto;
    min-height: 30vh;
    max-height: 80vh;
}

.timelineWrapper {
    line-height: 1.5em;
    font-size: 14px;
    width: 90%;
    margin: 30px auto;
    position: relative;
   
    // overflow-x: hidden;
//   overflow-y: scroll;
  
    @include prefix(transition, all .4s ease);
    
    &, 
    *, 
    *:before,
    *:after {
        box-sizing: border-box;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
    }

    &:before {
        content:"";
        width: 5px;
        height: 100%;
        background: #26C17E;
        left: 50%;
        top: 0;
        position: absolute;
        
    }

    &:after {
        content: "";
        clear: both;
        display: table;
        width: 100%;
        
    }
    
    .timeline-item {
        margin-bottom: 50px;
        position: relative;
        
        @extend %clearfix;

        .timeline-icon {
            background:white ;
            width: 50px;
            height: 50px;
            position: absolute;
            top: 0;
            left: 50%;
            // overflow: hidden;
            margin-left: -23px;
            @include prefix(border-radius, 50%);



            // .year {
            //  position: relative;
            //  text-align: center;
            //  //transform: translate(50%, 50%);
            // }
        }

        .year {
            position: absolute;
            top:-6px;

            font-family: Open Sans;
font-style: normal;
font-weight: bold;
font-size: 16px;
line-height: 120%;
            //transform: translate(50%, 50%);
        }

        .timeline-content {
            // width: 882px;
            background: #EEEEEE;
            padding: 10px 10px 5px 15px;
            position: relative;
            @include prefix(box-shadow, 0 3px 0 rgba(0,0,0,0.1));
            @include prefix(border-radius, 5px);
            // @include prefix(transition, all .3s ease);

            h2 {
                font-family: Open Sans;
font-style: normal;
font-weight: bold;
font-size: 16px;
line-height: 120%;
                // @include prefix(border-radius, 3px 3px 0 0);
...
            }

            p{
                font-family: Open Sans;
font-style: normal;
font-weight: normal;
font-size: 14px;
line-height: 150%;
padding-left: 5px;
            }

            &:before {
                content: '';
                position: absolute;
                top: 20px;
                right: -5px;
                width: 14px;
                height: 14px; 
                background-color: #EEEEEE;
                display: block;
                border-radius: 3px;
                transform: rotate(45deg);
            }

            &.right {
                float: right;

                &:before {
                    left: -5px;
                    right: inherit;
                }
            }
        }
    }
}

#timeline {
    // margin: 30px;
    // padding: 5px;;
    margin-left:10px;
    padding: 0;
    
    &:before {
        left: 15px;
    }
    
    .timeline-item {
        .timeline-content {
            // width: 95%;
            // float: right;
            margin-left:70px;
            // margin-left:40px;
            &:before,
            &.right:before {
                left: -5px;
                right: inherit;
            }
        }

        .timeline-icon {
            left: 15px;
        }
    }
}

.year{
    color:black;
    text-align:center;
    margin-top:20px;
}

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

Integrating CSS with Material-UI in a React project: A step-by-step guide

I am currently developing a project using React (along with TypeScript) and the Material-UI library. One of my requirements is to implement an animated submit button, while replacing the default one provided by the library. After some research, I came acr ...

Here are the steps to pass the selected dropdown value to ng-repeat for ordering:

I have a dropdown box with options for filtering data in an ng-repeat by different criteria. How can I pass the selected value from the dropdown to the ng-repeat orderby? Here is my dropdown: <select name='filter_range' id='filter_range ...

Having difficulty changing the value of a Select element in AngularJS

Struggling to update the select value from AngularJs. Check out my code below: <select ng-model="family.grade" > <option ng-repeat="option in options" value='{{option.id}}'>{{option.text}}</option> </s ...

What could be causing this jQuery color picker to malfunction when used inside a Bootstrap modal?

Currently, I am utilizing the fantastic jQuery color picker provided by Although it functions as expected in "normal" scenarios, I have encountered an issue where the picker fails to display when the input parent element is nested within a Bootstrap 3 mod ...

Discovering checkboxes in HTML using jQuery

Greetings! I have limited knowledge when it comes to using jQuery. I am currently facing an issue with the Checkbox attribute. Below, you will find the code snippet that I have mentioned: Code: $( this ).html() Output: <input name="cb_kot[]" class= ...

Transferring information between Vue.js components via data emissions

Greetings from my VueJS Table component! <b-table class="table table-striped" id="my-table" :items="items" :per-page="perPage" :current-page="currentPage" :fields="fields" @row-clicked="test" lg >< ...

Exploring the concept of multi-level mapping within Next.js

I'm currently facing an issue while trying to map over an object and display the desired result. The first mapping is working fine, but I am encountering problems with the second map inside the <ul> element. const data = [ { ti ...

Utilizing Google Tag Manager for Efficiently Managing Multiple Schema Product Reviews with JSON-LD and Variables

Currently, I am facing a challenge while using Google Tag Manager to incorporate Schema JSON-LD Product reviews on certain pages. Despite my efforts, I am unable to locate any relevant resources to resolve this issue. The main problem lies in informing GT ...

Encountering a build error when using the @babel parser on Netlify with npm

Lately, I've been facing numerous challenges with the babel parser, particularly related to config files. Presently, I'm encountering an error on Netlify: 3:56:37 AM: Installing npm packages using npm version 8.19.4 3:56:41 AM: npm ERR! code E404 ...

Are the maps intersecting within the field of vision?

I have 2 components in my angular application each showing a map from mapbox. Here is the code for one of the components: Component import { Component, OnInit } from '@angular/core'; import * as mapboxgl from 'mapbox-gl'; @Component( ...

AngularJS - Custom directive to extract a property value from an object

Currently, I am using the following for loop to retrieve the parent category: angular.forEach(queryTicketCategories, function(category) { if(category.id === $scope.ticketCategory.parentId) { $scope.parent = category; } }); I am looking fo ...

Is it possible to include several Relay fragments within a single React component?

Referencing an example from the documentation, there is a dilemma. What if additional data is required in the TodoItem component that is located elsewhere in the data graph and cannot be accessed through the Todo->TodoItem connection? class TodoItem ex ...

Adding dots between page numbers when using ReactJS/Javascript Pagination can be achieved by implementing a specific method

I have created a pagination component using React JS. Currently, it only displays all the page numbers, but I want it to show dots when there are more than 8 total pages. Here's how I envision it: c. When total is less than 9 pages: Page 1 selecte ...

Combining images with PHP

I have a collection of numerous images that are all the same size in terms of width and height. In total, there are over 50 unique images. My goal is to combine these images along both the horizontal (X) and vertical (Y) axes. Specifically, I would like ...

css element remains stationary and in view

Issue at hand: I have created a logo file named .art-obj1631017189 and I am looking to fix its position. It appears to work fine, but when scrolling down and it encounters the content section, my object falls behind the content (item-layout). I desire to ...

What is the best way to showcase information from an external API in react js?

As I develop my new app, I am integrating API data from . This feature will enable users to search for their favorite cocktail drinks and display the drink name fetched from the API on the page. However, I am encountering an error that says "Uncaught TypeE ...

Refresh the Angular view only when there are changes to the object's properties

I have a situation where I am fetching data every 15 seconds from my web API in my Angular application. This continuous polling is causing the Angular Material expansion panel to reset to its default position, resulting in a slow website performance and in ...

What could be causing the horizontal scroll bar to appear on the Web Page, even though it should fit perfectly on

I've designed this website to perfectly fit within the browser window, but for some reason, there's a horizontal scrollbar appearing. When a site fits properly, there shouldn't be a need for a horizontal scroll bar. I double-checked my zoom ...

Adding the active class in Bootstrap can be easily achieved in CodeIgniter by using the

I am seeking guidance on how to add an active class in CodeIgniter when dividing the view into three separate files. These files include: header.php page1.php ... page10.php footer.php According to this thread, there seems to be no clear solution prov ...

Hide popup using HTML when clicking outside of it

Currently, I have implemented Bootstrap Popover with HTML content using the code snippet below. This code is based on the answer provided at . $(".song-status-link").popover({ html: true, placement: 'bottom', ...