JSFiddle - React, Tailwind, and code Playground
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="js/timeline_test.js"></script>
</head>
<body>
<div class="container">
<div id="timelineDataContainer"><div id="timelineData"></div></div>
</div>
<div class="timeline">
<div id="timelineLimiter"> <!-- Hides the overflowing timelineScroll div -->
<div id="timelineScroll"> <!-- Contains the timeline and expands to fit -->
<div class="event">
<div class="eventHeading green">Example</div>
<ul class="eventList">
<li class="music">
BIG CONTENT<span class="active">ACTIVE</span><div class="content">
<div class="body"><div class="leftPane"><br />
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
...
CSS
div.container{
margin:0px auto;
width:900px;
}
div.timeline{
margin:0px auto;
width:950px;
margin-bottom:20px;
height:350px;
}
div#timelineData{
}
div.leftPane{
float:left;
width:220px;
}
div.rightPane{
float:right;
width:650px;
}
div#timelineDataContainer{
padding:4px;
clear:both;
width:100%;
display:none;
overflow:hidden
}
/* TIMELINE */
.event{
/* Contains the event header and body list */
float:left;
padding:4px;
text-align:left;
width:300px;
margin:0 5px 50px;
}
.eventList li{
/* The individual events */
background:#F4F4F4;
border:1px solid #EEEEEE;
list-style:none;
margin:5px;
padding:4px 7px;
}
.eventList li:hover{
/* The hover state: */
cursor:pointer;
background:#E6F8FF;
border:1px solid #D4E6EE;
color:#548DA5;
}
li span{
/* The event icon */
display:block;
float:left;
height:16px;
margin-right:5px;
width:16px;
}
div.content{
/* This div contains additional data for the content */
display:none;
}
.eventHeading{
/* The colorful year headings at the top */
font-size:14px;
margin:-5px -5px 10px;
padding:2px 5px;
text-align:center;
}
/* Three color styles for the headings: */
.eventHeading.chreme{
background:#FBF7F0;
border:1px solid #EEE4D4;
color:#A78B5F;
}
.eventHeading.blue{
background:#E6F8FF;
border:1px solid #D4E6EE;
color:#548DA5;
}
.eventHeading.green{
background:#E6FFDF none repeat scroll 0 0;
border:1px solid #C9E6C1;
color:#6EA85F;
}
#timelineLimiter{
/* Hides the overflowing timeline */
width:100%;
overflow:hidden;
padding-top:10px;
margin:40px 0;
}
#scroll{
/* The small timeline below the main one. Hidden here and shown by jQuery if JS is enabled: */
display:none;
height:20px;
background:#F5F5F5;
border:1px solid #EEEEEE;
...
JavaScript
$(document).ready(function() { /* This code is executed after the DOM has been completely loaded */
/* The number of event sections / years with events */
var tot = $('.event').length;
// Bind clicking an event in the timeline to display the content
$('.eventList li').click(function(e) {
showWindow('<div>' + $(this).find('div.content').html() + '</div>');
});
});
function showWindow(data) {
// extract data
var title = $('.title', data).text();
var date = $('.date', data).text();
var body = $('.body', data).html();
$('#timelineDataContainer').slideUp(400, function() {
$('#timelineData').queue(function() {
$(this).html('').
append('<a id="closeMe" style="text-decoration:underline;display:block;cursor:pointer;">Close</a><br/><h1 style="margin-bottom:10px;">' + title + '</h1><hr class="rule" style="width:894px;margin-left:4px"/>' + body).dequeue();
});
}
);
$('#timelineDataContainer').slideDown(400);
$("#closeMe").click(function() {
$('#timelineDataContainer').slideUp(400);
});
}