What is the best way to align inline circles created with CSS vertically as the screen size changes?

Looking for resources on how to create circles using CSS? It can be a bit tricky, but here is the code you need:

HTML

<div id="wrapper">
        <ul id="circles">
            <li>
                <div class="circle"><div>K</div></div>
                <div id="column"><p>Some text here</p> </div>
            </li>
            <li>
                <div class="circle"><div>T</div></div>
                <div id="column"><p>Some text here</p></div>
            </li>
            <li>
                <div class="circle"><div>R</div></div>
                <div id="column"><p>Some text here</p></div>
            </li>   
            <li>
                <div class="circle"><div>F</div></div>
                <div id="column"><p>Some text here</p></div>
            </li>
        </ul>       
</div>  

CSS

.circle {
width: 10em;
height: 0;
padding-bottom: 10em;
border-radius: 50em;
border: 0.1em solid white;
overflow: hidden;
background: transparent;
box-shadow: 0 0 3px gray;
}

.cirlce div {
float:left;
width:100%;
padding-top:50%;
line-height:1em;
margin-top:-0.5em;
text-align:center;
font-size: 7em; 
font-family: 'Raleway', sans-serif;
color:white;
}

#column {
    width: 13em;   
}

#circles {
margin: 0;
padding: 0;
list-style: none;
}

#circles li {
float: left;
width:22.5% ;
margin:1.25% ;
}

#wrapper {
max-width: 60em;
margin: 0 auto;
padding: 0 5%;
}

I've customized this for desktop size, but when I switch to mobile, the circles overlap. How can I make them stack vertically under each other based on screen size? Any solutions?

Tried tables, but they distorted the circles into ellipses.

Thanks in advance!

Answer №1

Adjust the CSS for #circles li to remove the width and allow them to stack instead of overlapping

.circle {
    display:table;
    width: 10em;
    height:10em;
    border-radius: 50%;
    overflow: hidden;
    background: transparent;
    box-shadow: 0 0 3px gray;
}

.circle div {
    display:table-cell;
    width:100%;
    height:100%;
    line-height:1em;
    text-align:center;
    vertical-align:middle;
    font-size: 7em;
    font-family:'Raleway', sans-serif;
    color:black;
}

#column {
    width: 13em;
}
#circles {
    margin: 0;
    padding: 0;
    list-style: none;
}
#circles li {
    float: left;
    margin:1.25%;
}
#wrapper {
    max-width: 60em;
    margin: 0 auto;
    padding: 0 5%;
}
<div id="wrapper">
    <ul id="circles">
        <li>
            <div class="circle">
                <div>K</div>
            </div>
            <div id="column">
                <p>Some text here</p>
            </div>
        </li>
        <li>
            <div class="circle">
                <div>T</div>
            </div>
            <div id="column">
                <p>Some text here</p>
            </div>
        </li>
        <li>
            <div class="circle">
                <div>R</div>
            </div>
            <div id="column">
                <p>Some text here</p>
            </div>
        </li>
        <li>
            <div class="circle">
                <div>F</div>
            </div>
            <div id="column">
                <p>Some text here</p>
            </div>
        </li>
    </ul>
</div>

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

Issue with submitting input fields that were dynamically added using jquery

I created a table where clicking on a td converts it into an input field with both name and value. The input fields are successfully generated, but they do not get submitted along with the form. In my HTML/PHP : <tr> <f ...

Textarea malfunctions if it includes HTML code

Here's a situation I'm facing. I'm setting up a basic text area with buttons for bold, link, img, and italics. When I enter plain text in the text area, everything works fine and the method is triggered as expected. But when I include HTML ...

Adjust the scroll position when the height of a div is modified

Imagine we have a large div A with a height value and below it are other divs B, C, and more. If the user is viewing divs B or C, and A reduces its height by half, the scrolling position will remain the same. However, divs B and C will move up by that amo ...

The combination of MUI CardContent and flexBox seems to have issues when used in conjunction with typography and chips

Take a look at this React code using MUI. It's designed to create a Card that showcases Character Information. const CharacterPreview = ({ characterKey }: CharacterPreviewProps) => { return ( <Card sx={{ maxWidth: 256, borderRadius: 4 }}&g ...

Taking on The Notch: How Can I Improve?

I'm currently working on a website for my friend's bar, but I'm facing an issue with Chrome where the content can't push past the "notch". Interestingly, Safari displays it fine on mobile, while Chrome has this unsightly white space. I ...

Using CSS3 translate will result in children becoming relatively positioned

I am facing an issue with a sidebar that contains 2 divs. <div class="sectionsContainer clearfix"><-- Sidebar --> <div class="leftSection pull-left"> <p>Maor</p> </div> <div class="rightSection pu ...

Vertically center text in an email within a div using HTML

i'm struggling to perfectly center the text within a div in an HTML email. While it appears fine in Browserview with proper line-height, issues arise in Apple Mail and Outlook where it doesn't align vertically. <div style='width: 80%; ...

Creating a persistent table header and first column in HTML tables

I am having trouble getting the header column to stick to the top along with the first column beneath it. Here's what I'm aiming for: https://i.stack.imgur.com/hzVt8.png Despite my efforts, I can't seem to make it work. I've experimen ...

Why is my md-button in Angular Material displaying as full-width?

Just a quick question, I created a simple page to experiment with Angular Material. On medium-sized devices, there is a button that toggles the side navigation, but for some reason, it expands to full width. There's no CSS or Material directives causi ...

The bootstrap modal is appearing correctly, but the content within it is not displaying properly

I've been working on a website and added a modal for signup. However, when the user clicks on the signup button, the modal appears but the content inside it is not clickable. Can someone please help me with this issue? Here is the code snippet I am us ...

Redirecting a CSS link on a website

I have a webpage with a "read more" option that redirects to the About Us page. When I click on "read more", the About Us page opens at the top, but I want it to redirect to the bottom of the About Us page. How can I achieve this? ...

Steps for styling the header of an Antd Collapse Panel

I'm attempting to modify the text color in the header of an ant panel. Below is the entire ant collapse component code: <Collapse accordion defaultActiveKey={defaultOpenPanel}> <StyledCollapsePanel key="tasksAssignedToMe" header={ ...

Performing a jQuery post request using AJAX and setting the content type

Greetings, here is the code snippet: <script type="text/javascript"> 14 $(document).ready(function() { 15 $('#find').click(function(){ 16 17 var amount = $(' ...

Making sure the checkbox stays selected in an angular environment

After experimenting with Angular 9 and a custom input, I achieved the following result => https://stackblitz.com/edit/angular-ivy-rgsatp My goal was to prevent users from disabling a radio button that is currently checked. Therefore, I made changes in ...

How can I add content to the body of a modal in Bootstrap 3?

My application has a button that, when clicked, is supposed to trigger a modal popup containing some data. I want the data in the modal to come from another application via a PHP file accessed through a URL. How can this be achieved? <?php echo '& ...

Customize PrimeNG component styles

Utilizing the PrimeNG OverlayPanel for a dropdown click feature, I am encountering an issue with moving the default left arrow to the right position. Despite trying various solutions, I have reached a dead end. Would you be able to provide me with some fr ...

Stop working to $(this) in jquery when clicking outside

I'm facing an issue with my code and would like some help. I have a button that toggles the visibility of a filter element, which is working fine. However, I now want to implement a "click outside" effect to close the filter when clicking on any body ...

Troubleshooting a Label Overlapping Problem in Materialize CSS

I've been working on a Materialize project and encountering an issue with pre-filled values in text boxes. Here is a snapshot of the problem: https://i.stack.imgur.com/u13jT.png <div class="input-field col s12 m6"> <input class="" id="us ...

Unable to view Bootstrap modal upon click

Whenever I attempt to display a modal using Bootstrap, it mysteriously appears upon page refresh but fails to show up when the button is clicked. Ideally, I want the modal to only appear when the user clicks on the button. The structure of my html file lo ...

What is the best method to retrieve particular HTML lines (containing a flex container) with IronPython?

Utilizing IronPython 2.7.9.0 in Grasshopper and Rhino, I am extracting data through web scraping from a specific widget on the following link: The code snippet being used is shown below import urllib import os web = urllib.urlopen(url) html = web.read() ...