Could the text inside the <li> element be aligned to the left of the bullets?

Hello everyone, it's my debut question on stackoverflow.com so please bear with me. My issue revolves around aligning the text within the <li> tags to the left of the markers.

.stages{
    list-style-type: none; 
    counter-reset: num;
    margin: 0 0 0 45px;
    padding: 15px;
    font-size: 12px;
}
.stages__working{
    position: relative; 
    margin: 0 ;
    padding: 8px 0 45px 20px;
    line-height: 1.4;
}
.stages__working::before {
    content: counter(num); 
    counter-increment: num;
    display: inline-block;
    position: absolute;
    top: 0;
    left: -23px;
    width: 30px;
    height: 30px;
    background: #95E1E1;
    color: #fff;
    text-align: center;
    line-height: 28px;
    font-size: 14px;
    border-radius: 50%;
}
.stages__working::after {
    content: "";
    position: absolute;
    left: -2%;
    background-color: #95E1E1;
    width: 5px;
    margin-top: 0;
    height: 85px;
    z-index: -1;
}

.end::after {
    display: none;
}
<ol class="stages">
    <li class="stages__working">Introduction to client, project description</li>
    <li class="stages__working">Showcasing our work samples, including Instagram link</li>
    <li class="stages__working">Processing order, gathering client data and forwarding to designer</li>
    <li class="stages__working">Presenting designer’s layout for client approval, discussing artwork details, making changes and adjustments.</li>
    <li class="stages__working">Selecting T-shirt, hoodie: color, size, fabric, manufacturer. Taking measurements if necessary.</li>
    <li class="stages__working">Layout is ready, T-shirt as well, moving forward to production</li>
    <li class="stages__working">Printing design on paper, determining location placement of artwork</li>
    <li class="stages__working">Order completed, packaging, adding instructions, planner as gift</li>
    <li class="stages__working end">Delivery via Indriver or self-pickup</li>
</ol>

The desired outcome should resemble the image shown in this picture enter image description here

I'm open to suggestions on how to achieve this. Thank you in advance!

Answer №1

To achieve left and right alignment using CSS, you can utilize the "nth:child(odd) & nth:child(even)" selector to easily configure your Timeline Layout.

        .stages{
    list-style-type: none; 
    counter-reset: num;
    margin: 0 0 0 45px;
    padding: 15px;
    font-size: 12px;
}
.stages__working{
    position: relative; 
    margin: 0 ;
    padding: 8px 0 45px 20px;
    line-height: 1.4;
}
.stages__working::before {
    content: counter(num); 
    counter-increment: num;
    display: inline-block;
    position: absolute;
    top: 0;
    left: -23px;
    width: 30px;
    height: 30px;
    background: #95E1E1;
    color: #fff;
    text-align: center;
    line-height: 28px;
    font-size: 14px;
    border-radius: 50%;
}
.stages__working::after {
    content: "";
    position: absolute;
    left: -2%;
    background-color: #95E1E1;
    width: 5px;
    margin-top: 0;
    height: 100%;
    z-index: -1;
}

.end::after {
    display: none;
}

/*add this CSS*/


ol.stages {
    max-width: 500px;
    margin: 0 auto;
}

ol.stages li.stages__working {
    max-width: 185px;
    font-family: sans-serif;
}

ol.stages li.stages__working:nth-child(even) {
    margin: 0 0 0 auto;
}

ol.stages li.stages__working:nth-child(odd)::after {
    left: unset;
    right: -50px;
    top: 30px;
}

ol.stages li.stages__working:nth-child(odd)::before {
    left: unset;
    right: -62px;
}

ol.stages li.stages__working:nth-child(even)::after {
    right: unset;
    left: -45px;
    top: 0;
}

ol.stages li.stages__working:nth-child(even)::before {
    right: unset;
    left: -57px;
}
<ol class="stages">
    <li class="stages__working">Introduction to the client, project description</li>
    <li class="stages__working">Showcasing our past work examples, including links to our Instagram page</li>
    <li class="stages__working">Processing the order, receiving input from the client, and forwarding it to the designer</li>
    <li class="stages__working">Presenting the design mockup to the client for approval, discussing details and making revisions</li>
    <li class="stages__working">Selecting t-shirts, hoodies: color, size, fabric, manufacturer. Taking measurements if necessary</li>
    <li class="stages__working">Finalizing the design, readying the apparel, and starting production</li>
    <li class="stages__working">Printing the design on paper, determining its placement location</li>
    <li class="stages__working">Order completion, packaging, including instructions, planner as a gift</li>
    <li class="stages__working end">Delivery via courier or self-pickup</li>
</ol>

Answer №2

Is it possible to achieve this using nth-child(odd)?
Additionally, this approach is responsive.

.stages{
    list-style-type: none; 
    counter-reset: num;
    margin: 0 45px 0 50% ;
    padding: 15px;
    font-size: 12px;
    max-width:100%;
    position: relative;
}
.stages__working{
    position: relative; 
    margin: 0 ;
    padding: 8px 30px 45px 30px;
    line-height: 1.4;
    width:500px;
    max-width:100%;
}
.stages__working::before {
    content: counter(num); 
    counter-increment: num;
    display: inline-block;
    position: absolute;
    top: 0;
    left: -13px;
    width: 30px;
    height: 30px;
    background: #95E1E1;
    color: #fff;
    text-align: center;
    line-height: 28px;
    font-size: 14px;
    border-radius: 50%;
}
.stages__working::after {
    content: "";
    position: absolute;
    left: 0%;
    top: 0;
    background-color: #95E1E1;
    width: 5px;
    margin-top: 0;
    height: 100%;
    z-index: -1;
}
.stages__working:nth-child(odd){
  text-align: right;
  transform: translateX(-100%);
}
.stages__working:nth-child(odd):after{
  left: 100%;
}

.stages__working:nth-child(odd):before{
  left: calc(100% - 13px);
}
.end::after {
    display: none;
}
<ol class="stages">
    <li class="stages__working">Client introduction, order description</li>
    <li class="stages__working">Showcasing our previous work examples and Instagram link 
        submission</li>
    <li class="stages__working">Order processing, collecting client's requirements and 
        forwarding them to the designer</li>
    <li class="stages__working">Presenting the design from the designer to the client for approval, 
        discussing drawing details, making changes, and revisions.</li>
    <li class="stages__working">Selection of t-shirts, hoodies: color, size, fabric, 
        manufacturer. Taking measurements if necessary.</li>
    <li class="stages__working">Finalizing the design, shirt ready, initiating the 
        production process</li>
    <li class="stages__working">Printing the design on paper, determining the layout of 
        the design</li>
    <li class="stages__working">Order completed, packaging done, including instructions, gift planner</li>
    <li class="stages__working end">Delivery via Indriver or pickup</li>
</ol>

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

When CSS animations are used on numerous elements, it can lead to variations in the speed of

I made an animation to move elements from the top to the bottom of a page. I have 4 objects with this animation applied, but for some reason, they are moving at different speeds. It's confusing me. What could be causing this inconsistency? body { ...

Creating a dynamic menu structure by tailoring it to the specific elements found on each page

Currently, I am facing issues while attempting to generate a dynamic menu based on the elements present on the page. Is there a way to develop a menu using the following code structure?: <div class="parent"> <div class="one child" id="first"& ...

Issues with the Content Editable Functionality

While working on my website, I encountered a strange issue. For some reason, I can't seem to get the contenteditable="true" attribute to work on the heading with the ID "hl". It would be awesome if someone could help me figure out how to mak ...

What is the best way to verify the authenticity of a entered captcha code in php?

I'm struggling with validating a captcha code in my registration form. I need to check if the entered captcha code is correct before allowing the user to complete the registration process. If the code is invalid, I want to display an error message. I ...

What steps should I take to send an html form for server-side validation once I have completed successful validation on the client side using jQuery

Currently, I'm immersed in a web application project where the registration page design has been successfully completed. jQuery has been utilized for input validation and everything seems to be functioning as intended. However, upon clicking the Regis ...

encountering an issue with the map function being undefined

I am currently working on a todo list and I want to be able to delete data stored in an array using the filter method. However, I am encountering an error with my code. Here is the snippet: const onDelete = (id) => { setaddItem((prevData) => { ...

What is the best way to change the color of a single line within a

Looking for a way to highlight the selected row using jQuery? Here's a scenario: you have a textarea with multiple lines, and you want to color the line that was clicked by the user. You might be using this code: $(document).on("mouseup", '#scro ...

Create a new division directly underneath the bootstrap column

Imagine having a bootstrap table like this: https://i.sstatic.net/kXHiP.jpg Now, if you want to click on a column and open a div with more details below it, is it achievable with CSS or JavaScript? https://i.sstatic.net/HIfkK.jpg I tried using the Metr ...

Transform Arabic numerals into Roman numerals using only CSS styling

Currently developing a custom theme for a website and faced with the restriction of not being able to use Javascript. My goal is to translate certain numbers into Roman numerals. I attempted the following: .score:before { counter-reset: mycounter att ...

The function is defined, but it cannot be set to null

Having trouble understanding this error message "Cannot set properties of null." I'm attempting to update the innerHTML with the output text from four functions that my button triggers. However, it seems to be stopping at the first function now even t ...

The <link> element in the HTML file referring to the stylesheet {% static 'css/style.css' %} is not functioning properly

I am having trouble aligning text to the center in VS Code when linking CSS to HTML. The 'center-aliend' property doesn't seem to work for me. Can someone point out what I might be doing wrong? I am trying to position the text 'Hello St ...

The Bootstrap theme showcases a narrower layout than its parent container

I'm struggling with managing the width of the bootstrap container and row. Inside the row, I've placed all the content, but for some reason, the sizes are showing differently on jsfiddle and the image preview. <!DOCTYPE html> <html lang ...

Increasing the height of a child div by 100% relative to its parent div using

In my latest project, I am incorporating Bootstrap cards and need to ensure compatibility with Chromium 57.xx for company-related reasons. However, I have encountered a problem that needs addressing. I applied height: 100% to the cards, which resulted in ...

Issue with consistency in the height of product card titles across rows

Looking for suggestions on achieving consistent card title height per row to ensure image alignment at the bottom. The solution should be responsive. Any CSS tips or jQuery plugins are welcome! I've searched online but haven't found a similar sol ...

AngularJS's ng-model is able to handle dynamic changes effortlessly

I am working with an array of objects that can be viewed https://i.sstatic.net/Fg1L8.png Within the dropdown box, I have names listed and a text box that displays the value from the selected object https://i.sstatic.net/rY0ET.png The input box is current ...

It appears that the query parameters are impacting the speed at which the page loads

I am currently developing a project on this platform. It is using c9.io, an innovative browser-based collaborative programming IDE. The index.php file includes the following script: <?php $path = ltrim($_SERVER['REQUEST_URI'], '/&ap ...

The sidebar momentarily shrinks before expanding again when the page is loaded

There is a sidebar on my website that can expand or collapse when a button is clicked. I have successfully saved its state in the localStorage, but there is a small issue that I need help with. When the page loads and there is no saved state in the localS ...

The function for clicking is malfunctioning

I've been working with a table where I can dynamically add rows using the clone function, as shown below: new_row = $(table_id+' tbody > tr:last').clone(true).removeAttr('id').insertAfter(table_id+' tbody > tr:last&apos ...

Changing the mat-icon when the sidenav is closed with a body click: a simple guide

My sidenav toggles when I click on a mat-icon, and I have successfully changed the mat-icon to indicate the sidenav status. However, I am facing an issue where the icon does not revert back to its original state when the sidenav is closed by clicking anywh ...

What is the reason for the color transition effect only functioning in CSS when set to "

Is there a way to make the text color change faster than everything else in the transition? It seems that on the first transition, the color won't work but works fine going back. Can anyone explain why this is happening? #home-section button { ...