3 steps to create a responsive timeline component for Vue app
In this post you will learn about how to create a Timeline component with Vuejs in 3 steps.
Step 1: Create a Timeline component with script codes bellow:
In script codes we defined a timelineData array contains all events that you want to show in timeline.
Step 2: binding your events in Vue template:
Step 3: put a bit of css codes bellow to your app
Result:
So easily, you can create this timeline component with React => React Responsive Timeline Component or with HTML and css => Create a responsive timeline with HTML and CSS
Step 1: Create a Timeline component with script codes bellow:
const timelineData = [ { datetime: "2019", event: "Something happened in 2019" }, { datetime: "2018", event: "Something happened in 2018" }, { datetime: "2017", event: "Something happened in 2017" }, { datetime: "2016", event: "Something happened in 2016" }, { datetime: "2015", event: "Something happened in 2015" } ]; export default { data(){ return { events: timelineData } } };
In script codes we defined a timelineData array contains all events that you want to show in timeline.
Step 2: binding your events in Vue template:
Step 3: put a bit of css codes bellow to your app
body { background-color: #6e97ea; } * { box-sizing: border-box; } .timeline { position: relative; max-width: 1200px; margin: 0 auto; } .timeline::after { content: ""; position: absolute; width: 3px; background-color: white; top: 0; bottom: 0; left: 50%; margin-left: -2px; } .timeline-item { padding: 10px 40px; position: relative; background-color: inherit; width: 50%; } .timeline-item::after { content: ""; position: absolute; width: 15px; height: 15px; right: -9px; background-color: #4caf50; border: 2px solid #fff; top: 22px; border-radius: 50%; z-index: 1; } .left { left: 0; } .right { left: 50%; } .left::before { content: " "; height: 0; position: absolute; top: 22px; width: 0; z-index: 1; right: 30px; border: medium solid white; border-width: 10px 0 10px 10px; border-color: transparent transparent transparent white; } .right::before { content: " "; height: 0; position: absolute; top: 22px; width: 0; z-index: 1; left: 30px; border: medium solid white; border-width: 10px 10px 10px 0; border-color: transparent white transparent transparent; } .right::after { left: -10px; } .content { padding: 20px 30px; background-color: white; position: relative; border-radius: 6px; } /* Responsive on screens less than 600px wide */ @media screen and (max-width: 600px) { .timeline::after { left: 31px; } .timeline-item { width: 100%; padding-left: 70px; padding-right: 25px; } .timeline-item::before { left: 60px; border: medium solid white; border-width: 10px 10px 10px 0; border-color: transparent white transparent transparent; } .left::after, .right::after { left: 21px; } .right { left: 0%; } }
Result:

So easily, you can create this timeline component with React => React Responsive Timeline Component or with HTML and css => Create a responsive timeline with HTML and CSS
Latest
Related
© 2019 4codev
Created with love by Sil.