developing a tri-step program to assist the user

Is there a way to create responsive circles with equal width and height, center the horizontal line, and also center the numbers in the middle of the circle?

.DCQ_Container {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.Progress_Bar {
  display: flex;
  justify-content: center;
  border: 3px solid royalblue;
  align-items: center;
}

.circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: whitesmoke;
  background-color: green;
  text-align: center;
}

.HR_line {
  border: 2px solid grey;
  flex-grow: 0.1;
  margin: 0;
}
<div class="DCQ_Container">
  <h1 class="Steps_Head"> DCQ Step 1 / 3 </h1>
  <div class="Progress_Bar">
    <div class="Circle_Text_Container">
      <div class="circle">
        <p>1</p>
      </div>
      <p>User Name</p>
    </div>
    <hr class="HR_line" />
    <div class="Circle_Text_Container">
      <div class="circle">
        <p>2</p>
      </div>
      <p>Location</p>
    </div>
    <hr class="HR_line" />
    <div class="Circle_Text_Container">
      <div class="circle">
        <p>3</p>
      </div>
      <p>Buisnesss</p>
    </div>
  </div>
</div>

Answer №1

If you want to move titles outside of the flex flow, here's how:

.Circle_Text_Container {
  position: relative; /* Establishes context for absolute positioning in child elements */
}

.Circle_Text_Container > p {
  position: absolute; /* Positioned relative to the last element with position set to relative */
  top: 100%; /* Distance from the top */
}

This ensures that the flex size matches the height of the circle.

To center text within circles, you can utilize flex properties like this:

.circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: whitesmoke;
  background-color: green;
  
  display: flex;
  align-items: center;
  justify-content: center;
}

By the way, there are various methods for centering content inside a div, to the point where it's almost become a meme. If you're curious, check out this StackOverflow Question addressing this common issue.

The final result will look something like this:

.DCQ_Container {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.Progress_Bar {
  display: flex;
  justify-content: center;
  border: 3px solid royalblue;
  align-items: center;
}

.Circle_Text_Container {
  position: relative; /* Establishes context for absolute positioning in child elements */
}

.Circle_Text_Container > p {
  position: absolute; /* Positioned relative to the last element with position set to relative */
  top: 100%; /* Distance from the top */
  left: 0;
  right: 0;
  text-align: center;
}

.circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: whitesmoke;
  background-color: green;
  display: flex;
  align-items: center;
  justify-content: center;
}

.HR_line {
  border: 2px solid grey;
  flex-grow: 0.1;
  margin: 0;
}
<div class="DCQ_Container">
  <h1 class="Steps_Head"> DCQ Step 1 / 3 </h1>
  <div class="Progress_Bar">
    <div class="Circle_Text_Container">
      <div class="circle">
        <p>1</p>
      </div>
      <p>User Name</p>
    </div>
    <hr class="HR_line" />
    <div class="Circle_Text_Container">
      <div class="circle">
        <p>2</p>
      </div>
      <p>Location</p>
    </div>
    <hr class="HR_line" />
    <div class="Circle_Text_Container">
      <div class="circle">
        <p>3</p>
      </div>
      <p>Buisnesss</p>
    </div>
  </div>
</div>

To adjust how far the text extends beyond the labels before and after the circle, you can modify the left and right properties on Circle_Text_Container > p.

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

Selenium Webdriver faced challenges in identifying dynamically created scripts using CSS selectors

I am in need of assistance with the following: Requirement: On the homepage, there is a navigation menu bar that changes appearance when scrolling down. This change is reflected in the body class name switching from "home" to "home scriptable persistent-o ...

Activate jquery code during interaction

I am in need of a scalable image that can be centered within a scalable <div>. Currently, I have a wrapper <div> along with the scalable <div> that contains the image. Additionally, there is some jQuery code in place to calculate the widt ...

Checking the validity of user input statements

When 2 conditions are met, both error links and messages will display on top of each other. If an input is 0, the validation statement for empty inputs will also trigger. Additionally, if one input is not numeric but the other is, PHP will calculate the va ...

What is the best method for displaying the toggle button for Drawer/Sidebar above the main content and appbar?

After reviewing Vatsal's suggestion, it appears that moving the toggle button above the drawer is the solution to our main issue. By taking advantage of the open state of the drawer, we can adjust the left property of the button in the toggleButton cl ...

Tips for preserving dynamically generated HTML through Javascript during page reload

I have a straightforward question, but I haven't been able to find a suitable answer. Here's my situation: On my HTML page, I have a form. Using jQuery and AJAX, I submit the form and then use some JavaScript code to change the content of a spec ...

The checkbox is failing to display as checked even after its value has been dynamically set to true

Currently, I am immersed in a project within ASP.NET MVC that involves displaying data on a page where users can interact by selecting checkboxes to make changes. In cases where there are numerous checkboxes present, a "Select all Checkboxes" button become ...

What causes divs to be interspersed among other divs when Float is enabled?

I am looking to create a layout for 4 sections, similar to a table, utilizing only divs and CSS. The intended output is this: Logo-----------Info Business-------Client I initially thought it would be simple by using the Float property. However, when I se ...

Build a bootstrap table with rounded corners

Currently, I am utilizing Bootstrap 5 and have the table code below: .reasonCode-table { padding: 8px; border-collapse: separate; } .reasonCode-table th { border: 2px solid #7a7878; padding: 8px; border-radius: 2px; border-collapse: collaps ...

Error: Trying to access the parent node of an undefined property

After incorporating this script into my webpage for the newsletter sign-up process, I aimed to reveal customized content post user subscription. <script> function insertAfter(referenceNode, newNode) { referenceNode.parentNode.insertBefore(newNode ...

What steps can I take to ensure that the full tingle modal, which includes an image, is visible when the

Upon loading the page, I noticed that if the browser width is greater than 540px, the modal displaying an image gets cut off (see figure below). What steps should I take to ensure that the vertical scroll bar appears immediately? https://i.sstatic.net/cJv ...

Developing a system mode called "night mode"

I've decided to incorporate a dark mode feature into my Wordpress theme. Creating both dark and light modes was a breeze, but now I want to add a third mode that serves as the default for pages. This new mode will automatically switch between dark a ...

.mouseleave() triggers when exiting a designated boundary area

I'm attempting to implement a roll-up feature for a div when the mouse is over another div. The issue I'm facing is that the roll-up div closes even if the mouse just exits through the bottom border. Is there a way to achieve this using JavaScrip ...

When attempting to retrieve the value of my select element, I encounter difficulty due to a hidden field that only becomes visible when a certain option is selected

I have a dropdown menu with different options, including one labeled "other". When the user selects "other", a hidden text field appears for them to enter a custom value. This functionality works correctly. However, if the user selects any other option and ...

What is the reason behind Object.hasOwn(x,y) being different from Reflect.ownKeys(x).includes(y) when x represents a CSSStyleDeclaration object and y is a hyphenated property such as 'z-index'?

Both of these conditions are true: 'z-index' in getComputedStyle(document.body) // true Reflect.has(getComputedStyle(document.body), 'z-index') // true Additionally, the following statements also evaluate to true, indicating that &apo ...

section containing image on the left side and title and text on the right side

In order to replicate the layout shown in the image, I need to create a div. The left side should contain an image, while the right side should have a title and description below it. It's important to consider that the left side should take up roughly ...

Adapt to screen size changes by transforming a single row into two separate rows

I am trying to create a two-column row with inputs: <div class="row first-row"> <div class="column col-6"> <div class="form-group"> <label for="usr" >Se ...

Introduction to Flask with GAE (blank Firefox tab)

Recently, I completed the Getting Started with Flask on App Engine Standard Environment tutorial. If you are interested, you can find the source code here. During my testing using Firefox and Chrome, I noticed that both browsers did not render the HTML te ...

Modify button text when hovered over

Is it possible to modify the text color of "Contacte-nos" on hover? .popmake-contacte-nos { background-color: #fffff7; /* Green */ border: none; color: black; font-weight: bold; padding: 15px 32px; text-align: center; text-decoration: n ...

Setting up multiple classes in my unique situation

Setting up an ng-class in my app My current setup looks like this: $scope.myClass = 'class-A'; Performing a task here... $scope.myClass ='class-B'; Performing another task here $scope.myClass ='class-C'; html <div n ...

Tips for Embedding React into a Specific ID using Hooks on an HTML Document

I am currently diving into the world of React hooks. While I understand class components, Hooks seem to be missing a specific render section. When adding React to a webpage (without using CREATE REACT APP), how do I specify where my hook should run on the ...