Experiencing problems with lining up several circular items in a row

For my project, I am trying to showcase multiple circular shapes with percentages in a row, but I am encountering some issues.

I attempted using a div with display flex, but it doesn't seem to be working as expected. Here is what I have tried so far:

 .meal-circular-progress{
  position: relative;
  height: 100px;
  width: 100px;
  border-radius: 50%;
  background: conic-gradient(#7d2ae8 0deg, #ededed 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin:auto;
 //transition: background 2s;
 //transition-timing-function: ease; 
 //border: 1px solid red;
}
.meal-circular-progress::before{
  content: "";
  position: absolute;
  height: 80px;
  width: 80px;
  border-radius: 50%;
  background-color: #fff;
//border: 1px solid red;
}



.progress-value{
   position: relative;
   font-size: 40px;
   font-weight: 600;
   color: #7d2ae8;
}
<div class="col-sm-6  center">
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
</div>

Answer №1

To achieve the desired layout, the parent element needs to be set to flexbox. In this case, the parent element is named center.

To make the element a flexbox, use the align-items property as shown below:

  .center {
      display: flex;
      align-items: center;
      justify-content: center;
  }

 .meal-circular-progress {
      position: relative;
      height: 100px;
      width: 100px;
      border-radius: 50%;
      background: conic-gradient(#7d2ae8 0deg, #ededed 0deg);
      display: flex;
      align-items: center;
      justify-content: center;
      margin: auto;
  }

 .meal-circular-progress::before {
      content: "";
      position: absolute;
      height: 80px;
      width: 80px;
      border-radius: 50%;
      background-color: #fff;
  }

  .progress-value {
       position: relative;
       font-size: 40px;
       font-weight: 600;
       color: #7d2ae8;
   }
<div class="col-sm-6  center">
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">5%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">20%</span>
      </div>
</div>

Answer №2

Utilize flexbox for the container

https://codepen.io/mplungjan/pen/xxJEPwx

#container {
  display: flex;
  flex-direction: row;
  min-width: max-content;
  max-width: max-content; /* can be omitted */
  border: 1px solid black;
}

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

Incorporating a helper JavaScript file to seamlessly integrate Typeform into a project built with Vue

Struggling with incorporating a typeform into my website through the use of both vue and laravel. The problem arises when trying to embed the typeform using a script, as Vue throws an error when attempting to include the script directly within the compone ...

Undefined reference to Kendo UI Grid in AngularJS was encountered

Recently, I've been working on integrating Kendo UI with AngularJS. Despite being new to AngularJS, I'm trying my best to follow the guidelines. However, I've encountered an issue that I can't seem to solve - I am unable to obtain a ref ...

"How to prevent users from using the back button on Google Chrome and Edge browsers

window.history.pushState(null, null, location.href); window.addEventListener('popstate', () => { history.go(1); alert('The use of back button is restricted.'); }); An issue has been identified where the code snippet above d ...

Extracting keys and values from a JSON string for analysis

My current code for the service now rest outbound call is functioning correctly. However, I am facing issues while trying to parse the JSON body in the second REST call and fetch values in the desired table format. try { var r = new sn_ws.RESTMessageV2 ...

Laravel route does not receive a parameter sent via Ajax

I am currently using Laravel 5.8 and implementing a discount code system on my website. To achieve this, I attempted to send data via Ajax in the following manner: $.ajax({ type: 'POST', url: baseurl + 'discount/register', ...

Troubleshooting problems with routing for an Angular 5 single page application when serving it from a Lumen 5.2 controller

I am facing an issue with serving an Angular SPA from a single routed Lumen endpoint. While the initial boot of the Angular application works fine when navigating directly to the endpoint, loading any child route of the Angular SPA does not work properly. ...

Integrating tilt and zoom functionality on a web page based on mouse movements

While browsing through some messages on chat, I came across something interesting: I noticed that as I moved my mouse left or right, the content would tilt in that direction, and when moving up and down, the content would zoom in or out. It was a really c ...

Ways to conceal the scroll bar upon the initial loading of a webpage

Recently, I created a single-page website consisting of 4 sections. The client has specific requirements that need to be fulfilled: The scrollbar should not be visible when the page loads. Once the user starts scrolling past the second section, the scrol ...

Form featuring two buttons with distinct values for submitting

<form action="here.php" method="POST"> <input type="text" name="text"> <div id="one"> <input type="hidden" name="aaa" value="one"> <input type="submit" value="Send"> </div> <div id="two"> <input type= ...

Creating the Apk file for your sencha touch application

Hello there! I'm diving into the world of Sencha Touch as a new user. After installing all the required tools and SDK, I successfully set up the demo example that came with project creation via command line. Now, I'm eager to generate the APK fil ...

Update the dropdown field selection to the color #333 with the help of javascript

I am facing an issue with a dropdown field that has placeholder text and options to select. Initially, both the placeholder text and the options were in color #333. However, I managed to change the color of the placeholder text to light grey using the foll ...

What could be causing my cross fade to not repeat as intended?

I created a basic background image cross fader using the code found at http://jsfiddle.net/jRDkm/2/. This code was inspired by . However, I'm encountering an issue where the slideshow only repeats once before fading to white. How can I modify the cod ...

Converting objects to arrays in Typescript: A step-by-step guide

Can anyone assist me in converting a string to a Typescript array? Any help would be greatly appreciated. Take a look at the following code snippet: private validateEmptyOption(): any { console.log("CHECKED") let isValid = true; this.currentF ...

Tailored vertical dimensions in Boostrap with varying width and height styles

Trying to position a vertical icon on a profile photo card inside a div to be in the center of a white box but it's not working. Using style="width: 300px; height: 300px; for the div square centers it horizontally, but not vertically. Can someone help ...

Creating individual product pages from an array of objects: A step-by-step guide

Is there a way in Next.js to create individual pages for each object in an array with unique URLs? Here is the input array: Input Array const products = [ { url: "item-1", id: 1, name: "Item 1", description: "lor ...

Use CSS to position three buttons in the center of a row by aligning them horizontally

I need help aligning three buttons in the same row and centered vertically. I want them to be aligned in the same way as the text "Select your attack:" Please advise on how to achieve this alignment. .prompt_user_to_choose { margin: 0; display: flex; ...

What causes the tweets' IDs to be altered by axios when parsing the response from the Twitter search API?

I am currently utilizing axios to send a GET request to the Twitter search API in order to fetch recent tweets that utilize a specific hashtag. To begin with, I ran tests on the twitter search API via Postman and noticed that the id and id_str tweet statu ...

What are the steps to use grunt for running a node.js application?

Directory Structure: myapp --public(directory) //contains files related to public (AngularJS, CSS, etc) --server(directory) //contains files related to server --server.js Code server.js //located at root directory ---------------------- ... var app = ...

Transformation of CSS classes in React with Webpack

Have you ever noticed that when you inspect the Airbnb website, the classnames appear to be morphed into single alphanumeric names? What is the name of this technique and is it applied at the code level or build level? https://i.sstatic.net/qSiaj.jpg ...

The jquery and operator fails to function

I am encountering an issue with the code snippet below. The functionality involves a button that toggles a div. Within this toggle div, there are several other divs and elements. $(function () { $('#btn').click(function (e) { e.preve ...