Overreaching line surpassing its containing box

I have a specific HTML setup that includes CSS styling for rows, circles, and lines:

.row.justify-content-center div:last-child>div>div {
  display: none;
}

.line {
  width: 100%;
  height: 9px;
  margin-left: 16px;
  border-bottom: 2px solid lightgrey;
  position: absolute;
}

.circle {
  height: 16px;
  width: 16px;
  background-color: lightgrey;
  border-radius: 50%;
  display: inline-block;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73111c1c07000701120333475d435d43">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="align-text-center">
    <div class="row justify-content-center">
        <div class="col-1 text-center">
            <div id="step-1" class="circle">
                <div class="line"></div>
            </div>
            <div class="d-none d-md-block">
                <p class="small">Step 1</p>
            </div>
        </div>
        <div class="col-1 text-center">
            <div id="step-2" class="circle">
                <div class="line"></div>
            </div>
            <div class="d-none d-md-block">
                <p class="small">Step 2</p>
            </div>
        </div>
        <div class="col-1 text-center">
            <div id="step-3" class="circle">
                <div class="line"></div>
            </div>
            <div class="d-none d-md-block">
                <p class="small">Step 3</p>
            </div>
        </div>
    </div>
</div>

However, when I view this layout on smaller screens such as an iPhone 12, the line extends beyond its intended container. Here is an image showing the issue: https://i.sstatic.net/hmDZg.png

The width of the line is set to 100%, but it still overflows. How can I correct this problem?

Answer №1

The position of the line is set to absolute, so it aligns with its relative parent col-sm-1 rather than the circle class element. If we remove this absolute positioning, the width will be determined by the circle element instead.

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

How can I modify the parent form element to only evaluate the expression at the text node, without affecting Angular interpolation?

Currently, I am in the process of developing an eCommerce platform and utilizing angular to construct a widget on product detail pages. Unfortunately, my control over the initial HTML rendered for the browser is quite limited. While most tasks related to m ...

How can I align the text in a dropdown menu to the center on Safari?

How can I center the option text in a drop down menu using CSS? display: block; height: 60px; margin-left: 10%; margin-right: 10%; margin-top: 10px; min-height: 60px; text-align: center; The option text is centered in Firefox browser, but not in Safari. ...

Styling list items (li) on hover without using the li:

I have a menu where I am using the :after element. When I hover over a li in the menu, the hover effect also includes the :after element. HTML: <ul class="main-menu"> <li class="active"><a href="">Menu</a></li> <l ...

How can I stop a child node from inheriting any css styles from its parent node?

Imagine a body element with a nested child element (like a div). The body element may have unique CSS styles that are not predetermined (they depend on the specific webpage accessed on the internet). The child element (e.g. div) has a set of fixed CSS s ...

Having some vertical alignment problems in Bootstrap 4 with float-right

My template includes a comments section where I have used the w-75 float-right class, but this causes the other column to be pulled to the side where the comments are displayed. https://i.sstatic.net/HSnGT.png Below is the code snippet from my template: ...

Experiencing difficulties with JavaScript/jQuery when encountering the 'use strict' error

I have been working on a small function to change the background of an HTML file, but I keep getting the 'Missing 'use strict' statement' error message from JSLint despite trying multiple solutions. Can anyone suggest how to resolve th ...

The surprising height discrepancy in the li element while using the jQuery sortable plugin

After implementing this plugin, everything was running smoothly except for one minor bug that I encountered - the li element was displaying an unexpected height. To replicate this issue, follow these steps: 1. Open the sortable demo in Internet Explorer an ...

Issue with jQuery scrolling functionality

Can someone explain why the site is loading in this specific part of the page? My guess is that it has something to do with jQuery. You can view the live website here: Instead of loading in the home section, the site is loading in the portfolio section. I ...

Align the text field value with the corresponding tooltip content in Vuetify

<v-col class="d-flex align-center"> <v-tooltip bottom> <template v-slot:activator="{ on }"> <v-text-field v-on="on" :value="info.payeeNo" den ...

Modify the drop-down value based on the selection of a checkbox in HTML

Here is the updated version that I am stuck with. <base href="http://skins4device.com"/> <link rel="stylesheet" href="/gasss/css/ghd.css" type="text/css" media="all"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.m ...

Display or conceal various content within div elements using multiple buttons

I have a set of 5 image buttons, each meant to trigger different content within a div. When the page loads, there should be default content displayed in the div that gets replaced by the content of the button clicked. The previously displayed content shoul ...

Replicating Images in a Drag and Drop Layout

I am encountering an issue with my drag and drop feature, where dragging an image within the grid results in copying it instead of moving it. Below is the relevant code snippet: function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ...

What is the best way to keep the heights of two divs in sync?

Is there a way to make two divs have the same height, even though their content determines their individual heights? I am looking for a solution that doesn't involve using a table or a parent div. I'm new to JavaScript, so I'm hoping there i ...

Issues with align-content in Internet Explorer 11

.row { background: green; color: white; margin-top: 20px; } .col2 { border: 3px solid black; display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-end; } <link rel="stylesheet" href="https://stackpath.bootstrapcdn. ...

Discrepancy in Code Outputs

Last night, I spent some time testing out code for basic functions. To preview my work, I used two platforms - Dash and JSFiddle. Everything seemed to be running smoothly on both sites. However, when I uploaded the code to my live website, none of the butt ...

-moz-box-reflect - Styling for FireFox

I've been attempting to achieve a similar effect to this tutorial at http://designshack.net/tutorialexamples/HoverEffects/Ex5.html. However, I'm encountering issues with getting the reflection of the image to display properly in IE and Firefox. H ...

Conceal your password using HTML techniques

My goal is to hide passwords from being visible unless a user hovers directly over them. I've tried using the code below, but the hover effect isn't working as expected - either the password disappears completely or remains visible at all times. ...

What is causing the discrepancy between the appearance of my fiddle and my page?

Hey there, I encountered an issue while working on a page using jsFiddle - it seems to be behaving differently when viewed on the actual website! If you want to take a look: http://jsfiddle.net/8Hpmj/8/ http://ktaadn.me/about/ The example at ktaadn.me do ...

Is there a way to eliminate the horizontal line in my Table design?

Is there a way to eliminate the horizontal line from the table? css, html <table border="1" style="width:100%; border-collapse: collapse"> <tr> <th>Prepared By:</th> <th>Released ...

Eliminating the Scrollbar from Bootstrap 4 DataTable Causes Table Width to Decrease

My tables are causing a horizontal scroll bar to appear when converted to Bootstrap data tables. Adding the "p-3" class to the table's div for padding eliminates the scroll bar but also narrows the table. Is there a solution to removing the scroll b ...