What steps can I take to incorporate more sections into this timeline?

I discovered a timeline on codepen that I want to incorporate into my website.

The challenge lies in the fact that it only has three sections (semantic, relative, contained). I attempted to add two more sections, but this caused the layout to break and lose its responsiveness.

Can someone provide guidance on how to include additional sections in the timeline without compromising its responsiveness?

HTML:

  <!-- STEPS -->
  <section id="Steps" class="steps-section">

    <h2 class="steps-header">
      Responsive Semantic Timeline
    </h2>

    <div class="steps-timeline">

      <div class="steps-one">
        <img class="steps-img" src="http://placehold.it/50/3498DB/FFFFFF" alt="" />
        <h3 class="steps-name">
          Semantic
        </h3>
        <p class="steps-description">
          The timeline is created using negative margins and a top border.
        </p>
      </div>

      <div class="steps-two">
        <img class="steps-img" src="http://placehold.it/50/3498DB/FFFFFF" alt="" />
        <h3 class="steps-name">
          Relative
        </h3>
        <p class="steps-description">
           All elements are positioned realtive to the parent. No absolute positioning.
        </p>
      </div>

      <div class="steps-three">
        <img class="steps-img" src="http://placehold.it/50/3498DB/FFFFFF" alt="" />
        <h3 class="steps-name">
          Contained
        </h3>
        <p class="steps-description">
           The timeline does not extend past the first and last elements.
        </p>
      </div>

    </div><!-- /.steps-timeline -->

  </section>

CSS:

$outline-width: 0;
$break-point: 500px;

@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);

html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}
body {
  font-family: lato;
}

$gray-base:     #999999;
$brand-primary: #3498DB; //Zen Blue

.section-header {
  color: $brand-primary;
  font-weight: 400;
  font-size: 1.4em;
}


.steps-header {
  @extend .section-header;
  margin-bottom: 20px;  
  text-align: center;
}
.steps-timeline {
  outline: 1px dashed rgba(red, $outline-width);

  @media screen and (max-width: $break-point) {
    border-left: 2px solid $brand-primary;
    margin-left: 25px;
  }

  @media screen and (min-width: $break-point) {
    border-top: 2px solid $brand-primary;
    padding-top: 20px;
    margin-top: 40px;
    margin-left: 16.65%;
    margin-right: 16.65%;
  }

  &:after {
    content: "";
    display: table;
    clear: both;
  }
}
.steps-one,
.steps-two,
.steps-three {
  outline: 1px dashed rgba(green, $outline-width);

  @media screen and (max-width: $break-point) {
    margin-left: -25px;
  }

  @media screen and (min-width: $break-point) {
    float: left;
    width: 33%;  
    margin-top: -50px;
  }
}
.steps-one,
.steps-two {
  @media screen and (max-width: $break-point) {
    padding-bottom: 40px;
  }
}
.steps-one {
  @media screen and (min-width: $break-point) {
    margin-left: -16.65%;
    margin-right: 16.65%;
  }
}
.steps-two {

}
.steps-three {
  @media screen and (max-width: $break-point) {
    margin-bottom: -100%;
  }
  @media screen and (min-width: $break-point) {
    margin-left: 16.65%;
    margin-right: -16.65%;
  }
}

.steps-img {
  display: block;
  margin: auto;
  width: 50px;
  height: 50px;
  border-radius: 50%; 

  @media screen and (max-width: $break-point) {
    float: left;
    margin-right: 20px;
  }
}

.steps-name,
.steps-description {
  margin: 0;
}
.steps-name {
  @extend .section-header;

  @media screen and (min-width: $break-point) {
    text-align: center;
  }
}
.steps-description {
  overflow: hidden;

  @media screen and (min-width: $break-point) {
    text-align: center;
  }
}

Answer №1

Your CSS should be adjusted to incorporate more divs within the same width. Instead of manually assigning spacing between them, consider using a dynamic approach by experimenting with changing the width and margin properties. Make sure to include .step-four & .step-five in your css as well. To demonstrate, I have added an extra div for illustration purposes. Feel free to add more divs in a similar manner.

CSS

$outline-width: 0;
$break-point: 500px;
@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  font-family: lato;
}

$gray-base: #999999;
$brand-primary: #3498DB; //Zen Blue
.section-header {
  color: $brand-primary;
  font-weight: 400;
  font-size: 1.4em;
}

.steps-header {
  @extend .section-header;
  margin-bottom: 20px;
  text-align: center;
}

.steps-timeline {
  outline: 1px dashed rgba(red, $outline-width);
  @media screen and (max-width: $break-point) {
    border-left: 2px solid $brand-primary;
    margin-left: 0px;
  }
  @media screen and (min-width: $break-point) {
    border-top: 2px solid $brand-primary;
    padding-top: 20px;
    margin-top: 40px;
    margin-left: 10%;
    margin-right: 10%;
  }
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

.steps-one,
.steps-two,
.steps-three,
.steps-four,
.steps-five{
  outline: 1px dashed rgba(green, $outline-width);
  @media screen and (max-width: $break-point) {
    margin-left: -25px;
  }
  @media screen and (min-width: $break-point) {
    float: left;
    width: 25%;
    margin-top: -50px;
  }
}

.steps-one,
.steps-two {
  @media screen and (max-width: $break-point) {
    padding-bottom: 40px;
  }
}

.steps-one {
  @media screen and (min-width: $break-point) {
    margin-left: -12%;
    margin-right: 12%;
  }
}

.steps-two {}

.steps-three,.step-four{
  @media screen and (max-width: $break-point) {
    margin-bottom: -100%;
  }
  @media screen and (min-width: $break-point) {
    margin-left: 10%;
    margin-right: -10%;
    float:right;
  }
}


(steps-img) {
  display: block;
  margin: auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  @media screen and (max-width: $break-point) {
    float: left;
    margin-right: 10px;
  }
}

(steps-name,
steps-description) {
  margin: 0;
}

.steps-name {
  @extend .section-header;
  @media screen and (min-width: $break-point) {
    text-align: center;
  }
}

.steps-dsscription {
  overflow: hidden;
  @media screen and (min-width: $break-point) {
    text-align: center;
  }
}

The width property of the following can be changed based on the number of divs:

.steps-one,
.steps-two,
.steps-three,
.steps-four,
.steps-five{
  outline: 1px dashed rgba(green, $outline-width);
  @media screen and (max-width: $break-point) {
    margin-left: -25px;
  }
  @media screen and (min-width: $break-point) {
    float: left;
    width: 25%;
    margin-top: -50px;
  }
}

For Example

  • 3 divs - 33%
  • 4 divs - 25%
  • 5 divs - 20%
  • and so on

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance user experience with a flexbox navigation bar that dynamically adjusts link heights to ensure

I am struggling with making my navbar links the same height and keeping their text vertically centered, especially when they wrap onto multiple lines on a narrow viewport. While I have achieved vertical centering, I am facing difficulties in ensuring that ...

small screen right-side navigation with Bootstrap 4

My goal is to have the logo image on the left and the navigation on the right for xs devices, and the logo in the center with navigation on the left for sm devices. However, I am facing an issue where the navigation does not align to the right on xs device ...

Prevent the onClick function of the outer div from being triggered by clicking on the inner div

Similar Question: Stop parent container click event from firing when hyperlink clicked My issue is <div onClick="someJScode();"> ... <div></div> ... </div> I need to prevent someJScode() from executing when the inner di ...

How to create a dynamic height grid using Bootstrap?

Seeking assistance with implementing the layout shown in the image below using bootstrap 4. I am facing an issue with adjusting the height of div 1 and 2 dynamically based on the content in div 3. Can anyone provide some guidance? https://i.sstatic.net/mk ...

Tips on preventing a nested loop's inner ng-repeat from updating when the array undergoes changes

My current challenge involves working with an array of events, each event has teams participating in it. Although these objects are related, they are not properties of each other. I am attempting to loop through every event and display the teams participa ...

Use jQuery to trigger a click event when an element is in focus, unless it was clicked to

I am currently developing a website using the MDL framework. One issue I encountered is that there is no default select form element provided. After some research, I found a solution by utilizing a menu component that displays when the input is clicked. Th ...

What is the best way to align a collection of images in HTML and CSS?

Struggling to center five PNG images on a simple website for a friend. Previously, using display: block; and margin: auto; for one picture worked, as shown below. However, my current code: .middleContent{ width: 100%; top: 50px; p ...

Conceal a list item based on its specific value with the help of

I have a code snippet below where I need to hide the 'li' element by its value that is in the middle using JQuery. Here is the HTML: <ul id="tagCloud"> <li>Item1</li> <li>Item2</li> <li> ...

Prevent the left border from displaying on a link that wraps to a new line

Excuse me, I am facing an issue with a pipe separator in my subnav bar between links. The problem is that the first link on a new line retains the left-border that should be disabled. How can I prevent this border from appearing on the first link of a new ...

Adjusting the object-fit property to "contain" and combining it with border-radius or exploring other alternatives can enhance

My goal is to showcase videos on a webpage while utilizing border-radius to round the corners for a more aesthetically pleasing look. The challenge arises as the videos come in varying aspect ratios, requiring them to be accommodated within containers wit ...

What is causing the action button in my MUI snackbar to occupy an additional line?

I'm currently learning how to use MUI and I'm struggling with a specific issue. The close button in my code is appearing on a separate line, but I want it to be on the same line as the word "again". I've tried experimenting with absolute pos ...

Ways to make an element disappear when clicking outside of it in Angular 7 or with CSS

After entering text into an input field and pressing the space key, a div called 'showit' will be displayed. However, I want this div to hide when clicking outside of it. See the code below for reference: home.component.html <input type="tex ...

Adding an active class to a large image when a thumbnail image is clicked can enhance user experience and

I've created a photo gallery using jquery. Currently, when I click on "next", the image changes based on the index. However, I also want to be able to click on the thumbnails (small images) and display the larger image according to that specific inde ...

iPhone navigation glitch caused by jQuery and CSS

I have implemented a navigation that slides out from the right-hand side of my website when the menu button is clicked. However, there seems to be an issue with the transition on the navigation not working properly on iPhones. Here's how I've set ...

Checking and locating elements using Jquery's distinctive style

Within my code, I am searching for the DIV element that has the class .se and also has the attribute display: block. Once found, I need to retrieve the ID of this particular DIV. Unfortunately, it seems like my current approach is not correct. var usedse ...

The application of position "absolute" to center content is ineffective

When I have an h1 element with position "absolute" inside a div with position "relative", setting h1's top:50% and left:50% places it in the middle of the viewport instead of the parent div. It seems that the nearest parent is being ignored for some r ...

Styling with CSS in Zend Framework

In the process of creating a website using Zend Framework, I have successfully implemented the header, footer, and all the necessary pages. However, I am facing an issue with integrating the CSS file located at public/css/styles.css. When running the webs ...

What could be the reason my code isn't successfully performing addition within the input field?

As a novice, I am practicing by attempting to retrieve a number from a text field, prompting the user to click a button that adds 2 to that number, and then displaying the result through HTML. However, I keep encountering an issue where NaN is returned whe ...

Keep the division visible once the form has been successfully submitted

Initially, I have created 3 divs that are controlled using input type buttons. These buttons serve the purpose of displaying and hiding the hidden divs. Within these divs, there are forms to store data. Currently, my goal is to ensure that the div that was ...

The Laravel status check button consistently displays a value of 0 and does not update in the database

Hello, I have encountered an issue with my adminController. Despite checking the status box, it is being saved as zero in the database. I am unable to understand why the if/else block is not functioning properly. Even when I use debug, I can see that the c ...