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

Is it possible to import Vue directly from the "/path/to/vue.js" file without using npm or NodeJs?

Is it possible to build a web app using just a single index.js file and importing other available files like shown in this image: https://i.stack.imgur.com/02aFF.png encountering the error message: import not found: default Do you have to use Vuejs wit ...

Using AngularJS and JavaScript, set the Submit button to be enabled only when the email input is valid and a value is selected in

I'm trying to create a form that includes an email input field and a drop-down list sourced from a database array. Initially, the submit button is disabled when the form loads. My goal is to figure out how to activate the submit button only when the ...

Mobile Image Gallery by Adobe Edge

My current project involves using Adobe Edge Animate for the majority of my website, but I am looking to create a mobile version as well. In order to achieve this, I need to transition from onClick events to onTouch events. However, I am struggling to find ...

What is the best way to utilize withStyles in order to render a React component?

My question doesn't concern exporting, but rather how to return a React object with injected CSS. I am attempting to achieve the following: return ( withStyles(this.props.style)(<Component {...params}/>) ); The goal is to return Component wit ...

Passing state from a parent component to a child router component using React router-dom ends up displaying as undefined in the

Within the main component App.js, I am passing the user state to the child component Book: import React, { useEffect, useState } from "react"; import NavBar from "./components/NavBar"; import Signup from "./pages/Signup"; impo ...

The React Context Value keeps coming back as undefined every time

As a beginner working with contexts, I am taking it slow. Recently, I came across logging Providers to test the value and encountered a constant 'undefined' result. To troubleshoot, I tried moving them side by side in the code to see if it makes ...

Problems with Ajax calls are preventing Internet Explorer9 and Internet Explorer10 from functioning properly

I am facing an issue with displaying item pages using Ajax. The function works perfectly in Chrome, but not in Internet Explorer. <script type="text/javascript"> function obtainInfo(str) { if (str=="") { document. ...

Discover the process of loading one controller from another controller in Angular JS

Is it possible to load an entire controller1 from a different controller2, not just a function? ...

retrieve the date value of Focus+Context by using the Brushing Chart

Currently, I am engaged in analyzing the sentiment of tweets on Twitter. The analysis will produce an overall area graph that allows me to choose a specific date range and extract all or some of the tweets falling within that range. In order to create a t ...

Error encountered while rendering with ReactDOM and webpack

I encountered this perplexing error that I cannot seem to figure out, The line where I was rendering MuiThemeProvider in the react dom looks like this: ReactDOM.render( <MuiThemeProvider muiTheme={getMuiTheme()}> <Router history={browserHi ...

divs adjust their size based on how many are placed in a single row

I'm in the process of developing an online editing tool, and I'm interested to know if it's feasible to adjust the size of a <div> based on the number of visible div elements. For instance, I have a row with three columns, each set at ...

Dealing with the Spread operator in React and Redux causes issues

As a newcomer to the world of React and Redux, I find myself facing compilation errors while working on a reducer due to my attempt to utilize the spread operator. export default function chaptersReducer( state = { chapters: {}, isFetching: false, error ...

Encountering issues with resolving dependencies in webdriverIO

I'm attempting to execute my WebdriverIo Specs using (npm run test-local) and encountering an error even though I have all the necessary dependencies listed in my package.json as shown below: [0-2] Error: Failed to create a session. Error forwardin ...

Unveiling the hidden: Leveraging Python to extract elements not visible in HTML, yet present in Chrome's "Inspect Element" tool

Hello Python Experts! I'm diving into the world of Python and working on a program to retrieve data from a webpage. If the page returned all the information in its HTML source, there wouldn't be an issue as it's easily viewed in Chrome. Howe ...

Dynamically insert letters into each row as the HTML table increases

How can I display dynamically increasing alphabets in a newly generated cell on the left side of each row, based on the option selected in a dropdown list? These alphabets will serve as bullet points or serial numbers for the text boxes in each row. View ...

Modifying the URL does not alter the selected tab

As part of my project, I wanted to ensure that when the page is refreshed, the previously selected tab remains active. To achieve this, I created a basic HTML page and added some jQuery. However, I encountered an issue when manually changing the URL from ...

Leverage the Google Drive API for the storage of app-specific data

I'm currently developing a JavaScript application that runs on the client side and need to store a JSON object containing configuration details in a Google Drive Appdata file. Through the Google Drive API, I can successfully check for the file within ...

Angular material table featuring custom row design

My team is working with a large table that is sorted by date, and we are looking to add some guidance rows to help users navigate through the data more easily. The desired structure of the table is as follows: |_Header1_|_Header2_| | 25/11/2018 | ...

Using CSS to duplicate images in multiple repetitions horizontally

In the process of developing a UHD project that involves showcasing large images, I have encountered limitations with iOS and certain mobile browsers. While stationary browsers pose no issue, iOS only supports PNG images up to 5 megapixels in resolution, w ...

Sending NodeJS Buffer as form data to Spring Boot in a correct way

I'm facing an issue with my NodeJS application where I am working with an image buffer called qrCode const qrCodeData = Buffer.from(body).toString('base64'); //body received, not sure if base64 is correct f ...