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> </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;
}