Horje
How to Create a Horizontal Timeline in Bootstrap ?

A horizontal timeline is a graphical representation of events or milestones displayed horizontally along a linear axis. It’s a visual way to showcase a series of events or points in time, typically arranged from left to right. Each event may include details such as a title, date, description, and links for additional information.

Preview Image:

Screenshot-_180_

Output

Approach:

  • Create the HTML structure for the horizontal timeline using the <div>, heading, <p>, <ul>, <li> etc tags.
  • Now, add the bootstrap CSS and JavaScript CDN to include it in your HTML document and utilize it.
  • Use the grid system to organize the layout of the timeline. Typically, events are represented as cards or sections within a container element.
  • Apply custom CSS to achieve the desired visual appearance of the timeline, including line styles, spacing, and alignment.
  • Populate the timeline with events, including titles, descriptions, and links for additional information.

Example: The below code explains how you can use bootstrap to create a horizontal timeline.

HTML
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;

&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;title&gt;Horizontal Timeline - Bootstrap 5&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; href=
&quot;https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css&quot;&gt;
    &lt;style&gt;
        body {
            background: #eee;
            margin-top: 20px;
        }

        .hori-timeline .events {
            border-top: 3px solid green;
        }

        .hori-timeline .events 
        .event-list {
            display: block;
            position: relative;
            text-align: center;
            margin-right: 0;
        }

        .hori-timeline .events 
        .event-list:before {
            content: &quot;&quot;;
            position: absolute;
            height: 36px;
            border-right: 2px dashed #2ddf36;
            top: 0;
        }

        .hori-timeline .events .event-list 
        .event-date {
            position: absolute;
            top: 38px;
            left: 0;
            right: 0;
            width: 75px;
            margin: 0 auto;
            border-radius: 4px;
            padding: 2px 4px;
        }


        @media (min-width: 1140px) {
            .hori-timeline .events 
            .event-list {
                display: inline-block;
                width: 24%;
                padding-top: 45px;
            }

            .hori-timeline .events 
            .event-list .event-date {
                top: -12px;
            }
        }

        .card {
            border: none;
            margin-bottom: 24px;
            box-shadow: 0 0 13px 0 rgba(236, 236, 241, 0.44);
        }
    &lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;

    &lt;div class=&quot;container&quot;&gt;
        &lt;div class=&quot;row&quot;&gt;
            &lt;div class=&quot;col-lg-12&quot;&gt;
                &lt;div class=&quot;card&quot;&gt;
                    &lt;div class=&quot;card-body&quot;&gt;
                        &lt;h4 class=&quot;card-title mb-5 text-success&quot;&gt;
                            Bootstrap 5 Horizontal Timeline
                        &lt;/h4&gt;

                        &lt;div class=&quot;hori-timeline&quot; dir=&quot;ltr&quot;&gt;
                            &lt;ul class=&quot;list-inline events&quot;&gt;
                                &lt;li class=&quot;list-inline-item event-list&quot;&gt;
                                    &lt;div class=&quot;px-4&quot;&gt;

                                        &lt;h5 class=&quot;font-size-16 text-primary&quot;&gt;
                                            GPL 2021
                                        &lt;/h5&gt;

                                        &lt;p class=&quot;text-info&quot;&gt;
                                            This contest is over now and prize 
                                            distribution is over now thank you 
                                              for join. 
                                        &lt;/p&gt;
                                        &lt;div&gt;
                                            &lt;a href=&quot;/archive/&quot; 
                                               class=&quot;btn btn-success btn-sm&quot;&gt;
                                               Read more...
                                            &lt;/a&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;

                                &lt;/li&gt;
                                &lt;li class=&quot;list-inline-item event-list&quot;&gt;
                                    &lt;div class=&quot;px-4&quot;&gt;

                                        &lt;h5 class=&quot;font-size-16 text-warning&quot;&gt;
                                            GPL 2022

                                        &lt;/h5&gt;
                                        &lt;p class=&quot;text-muted&quot;&gt;
                                            This contest is over now check 
                                            your result in the dashbord section.
                                        &lt;/p&gt;
                                        &lt;div&gt;
                                            &lt;a href=&quot;/archive/&quot; 
                                               class=&quot;btn btn-success btn-sm&quot;&gt;
                                               Read more...
                                            &lt;/a&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/li&gt;
                                &lt;li class=&quot;list-inline-item event-list&quot;&gt;
                                    &lt;div class=&quot;px-4&quot;&gt;

                                        &lt;h5 class=&quot;font-size-16 text-danger&quot;&gt;
                                            GPL-2023
                                        &lt;/h5&gt;
                                        &lt;p class=&quot;text-primary&quot;&gt;
                                            This contest is over we start the 
                                            prize distribution soon please check 
                                            what you earn.
                                        &lt;/p&gt;
                                        &lt;div&gt;
                                            &lt;a href=&quot;/archive/&quot; 
                                               class=&quot;btn btn-success btn-sm&quot;&gt;
                                               Read more...
                                            &lt;/a&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/li&gt;
                                &lt;li class=&quot;list-inline-item event-list&quot;&gt;
                                    &lt;div class=&quot;px-4&quot;&gt;

                                        &lt;h5 class=&quot;font-size-16 text-success&quot;&gt;
                                            GPL 2024
                                        &lt;/h5&gt;
                                        &lt;p class=&quot;text-muted&quot;&gt;
                                            This contest comming soon you can show 
                                            it in the horje portal.
                                        &lt;/p&gt;
                                        &lt;div&gt;
                                            &lt;a href=
                                             &quot;/archive/&quot; 
                                               class=&quot;btn btn-success btn-sm&quot;&gt;
                                               Read more...
                                            &lt;/a&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/li&gt;
                            &lt;/ul&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;script src=
&quot;https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js&quot;&gt;
    &lt;/script&gt;
&lt;/body&gt;

&lt;/html&gt;

Output:

Screenshot-_180_

Output




Reffered: https://www.geeksforgeeks.org


Bootstrap

Related
What is use of d-none and d-block Classes in Bootstrap? What is use of d-none and d-block Classes in Bootstrap?
What is use of text-center Class in Bootstrap ? What is use of text-center Class in Bootstrap ?
What is use of the table-striped Class in Bootstrap ? What is use of the table-striped Class in Bootstrap ?
What is the use of justify-content Class in Bootstrap ? What is the use of justify-content Class in Bootstrap ?
How to Create a Three-Column Layout in Bootstrap? How to Create a Three-Column Layout in Bootstrap?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12