You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the help of Bootstrap Documentation, I actually managed to create something.
Here's the HTML section with the help of the examples in the position section in utilities (it's the second example) and started from there. I renamed the numbers to years and changed .m-4 to a margin to 1.55rem so it can fit in my container properly. Please note .start-33 and .start-66 are not in Bootstrap by default, add them yourself with the additional CSS below. The IDs in the HTML example are used in the JavaScript code sample, if you want to change the ID names, also remember to rename them in the JavaScript. The percentage change here is 33.33333333 (1/3), change the percentage depending on how many entries are there.
This requires JavaScript and JQuery. You can try to turn it into raw JavaScript if you like. I left describing comments in there if you want to take a look.
$(document).ready(function(){// Initialize the active button and set btn-primary for past yearsletactiveYear=1;updateTimeline(activeYear);// Add click event handlers to timeline buttonsfor(leti=1;i<=4;i++){$(`#history-${i}`).click(function(){if(i==activeYear)return;updateTimeline(i);});}// Function to update the timeline based on the selected yearfunctionupdateTimeline(year){// Remove the "active" class from all buttonsfor(leti=1;i<=4;i++){$(`#history-${i}`).toggleClass("active",i==year).toggleClass("btn-secondary",i>year).toggleClass("btn-primary",i<=year);}// Update the progress bar widthconstprogressBarWidth=(year-1)*33.33333333;$("#history-progress").css("width",`${progressBarWidth}%`);// Update the active yearactiveYear=year;}});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
With the help of Bootstrap Documentation, I actually managed to create something.
Here's the HTML section with the help of the examples in the position section in utilities (it's the second example) and started from there. I renamed the numbers to years and changed
.m-4
to a margin to 1.55rem so it can fit in my container properly. Please note.start-33
and.start-66
are not in Bootstrap by default, add them yourself with the additional CSS below. The IDs in the HTML example are used in the JavaScript code sample, if you want to change the ID names, also remember to rename them in the JavaScript. The percentage change here is 33.33333333 (1/3), change the percentage depending on how many entries are there.Static image if you want a look.
This requires JavaScript and JQuery. You can try to turn it into raw JavaScript if you like. I left describing comments in there if you want to take a look.
Additional CSS to
.start-33
and.start-66
.I'll post a video example of it working later.
Here's an example of me using it for the JavaScript part of tags.
Beta Was this translation helpful? Give feedback.
All reactions