`Having difficulty keeping an element in place on a webpage using HTML/CSS`

Struggling to create a segmented circle using HTML/CSS? Are you having issues with the left and bottom parts of the circle not staying fixed when the screen resolution changes? Here is the current code snippet:

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100&display=swap');

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #457CB0;
}

.circle {
    background: #457CB0;
    border: 50px solid rgba(255, 255, 255, .6);
    border-radius: 50%;
    box-shadow: 0.475em 0.475em 0.6em 0.6em rgba(15, 28, 63, 0.125);
    height: 27em;
    width: 27em;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}

.cirlce2 {
    border: 20px dashed rgba(255, 255, 255, .6);
    border-radius: 70%;
    height: 25em;
    width: 25em;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}

.myCircle2 {
    border: 20px solid rgba(255, 255, 255, 0);
    border-radius: 70%;
    height: 7.2em;
    width: 7.2em;
    background-color: #457CB0;
    z-index: 1;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}

.textCircle {
    color: #ffffff;
    position: absolute;
    width: 155px;
    height: 250px;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: -1px;
}

.myCircle3 {
    border-bottom: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 320px;
    width: 320px;
    border-radius: 250px 250px 250px 250px;
    background-color: rgba(255, 255, 255, .3);
    border-bottom: 0;
    border: 100px solid rgba(255, 255, 255, 0);
}

.div {
    position: absolute;
    top: 60.25%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 152px;
    width: 320px;
    border-radius: 0 0 150px 150px;
    background-color: #457CB0;
}

.myCircle4 {
    border: 7px solid #457CB0;
    border-radius: 50%;
    height: 21em;
    width: 21em;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    z-index: 1;
}

.bottom-right-quarter-circle {
    height: 145px;
    width: 155px;
    top: 51.9%;
    left: 50.3%;
    position: absolute;
    border-radius: 0 0 250px 0;
    background-color: rgba(255, 255, 255, .3);
}

.bottom-left {
    height: 145px;
    width: 155px;
    top: 51.9%;
    left: 37.5%;
    position: absolute;
    margin: auto;
    display: block;
    border-radius: 0 0 0 250px;
    background-color: rgba(255, 255, 255, .3);
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Circle</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="CircleType-master/dist/circletype.min.js"></script>
    <link rel="stylesheet" href="circle.css">
</head>

<body class="bg">

    <div class="circle"></div>

    <div class="cirlce2"></div>
    <div class="myCircle"></div>
    <div class="myCircle2"></div>
    <div class="myCircle3"></div>
    <div class="myCircle4"></div>

<div class="div"></div>

    <div class="bottom-right-quarter-circle"></div>
    <div class="bottom-left"></div>

</body>

</html>

Specifically looking at the code for the left and bottom sections:

<div class="bottom-left"></div>
<div class="div"></div>

.bottom-left {
    height: 145px;
    width: 155px;
    top: 51.9%;
    left: 37.5%;
    position: absolute;
    margin: auto;
    display: block;
    border-radius: 0 0 0 250px;
    background-color: rgba(255, 255, 255, .3);
}
.div {
    position: absolute;
    top: 60.25%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 152px;
    width: 320px;
    border-radius: 0 0 150px 150px;
    background-color: #457CB0;
}

Answer №1

To establish a relationship between the divs, it is recommended to nest them within each other.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Circle</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="CircleType-master/dist/circletype.min.js"></script>
</head>

<body class="bg">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100&display=swap');
        html,
        body {
            height: 100%;
            margin: 0;
            padding: 0;
            background-color: #457CB0;
        }
        
        .circle {
            background: #457CB0;
            border: 50px solid rgba(255, 255, 255, .6);
            border-radius: 50%;
            box-shadow: 0.475em 0.475em 0.6em 0.6em rgba(15, 28, 63, 0.125);
            height: 27em;
            width: 27em;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
        }
        
        .cirlce2 {
            border: 20px dashed rgba(255, 255, 255, .6);
            border-radius: 70%;
            height: 25em;
            width: 25em;
            top: 0rem;
            left: -0.15rem;
            position: absolute;
            margin: -2rem 0rem 0rem -2rem;
        }
        
        .myCircle3 {
            border-bottom: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            height: 320px;
            width: 320px;
            border-radius: 250px 250px 250px 250px;
            background-color: rgba(255, 255, 255, .3);
            border-bottom: 0;
            border: 100px solid rgba(255, 255, 255, 0);
        }
        
        .div {
            position: absolute;
            top: 10.33rem;
            left: 10.33rem;
            border-radius: 100%;
            transform: translate(-50%, -50%);
            height: 152px;
            width: 152px;
            background-color: #457CB0;
        }
        
        .myCircle4 {
            border: 7px solid #457CB0;
            border-radius: 50%;
            height: 21em;
            width: 21em;
            top: -.1rem;
            left: -0.1rem;
            position: absolute;
            margin: auto;
            z-index: 1;
        }
        
        .bottom-right-quarter-circle {
            height: 20px;
            width: 325px;
            left: -6.25rem;
            top: 40%;
            position: absolute;
            background-color: #457CB0;
            z-index: 50;
        }
        
        .bottom-left {
            height: 140px;
            width: 20px;
            bottom: -6.7rem;
            left: 3.3rem;
            position: absolute;
            margin: auto;
            display: block;
            border-radius: 250px;
            background-color: #457CB0;
        }
    </style>

    <div class="circle">
        <div class="cirlce2"></div>
        <div class="myCircle3">
            <div class="bottom-right-quarter-circle"></div>
            <div class="bottom-left"></div>
        </div>
        <div class="div"></div>
        <div class="myCircle4"></div>
    </div>





</body>

</html>

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

Swipe and tap on smartphones and tablets

After successfully creating a drag and drop jquery quiz for desktops using jquery and jquery ui, my goal is to make it compatible with mobile and tablet devices as well without making any changes to the current code. I tested touch punch but it didn't ...

Azure experiencing issue with MUI Datepicker where selected date is shifted by one day

I have developed a unique custom date selection component that utilizes Material UI and Formik. This component passes the selected date value to a parent form component in the following manner: import React from 'react'; import { useField } from ...

Looking to display a page header alongside an image on the same page

I'm currently learning React.js and working on my very first app. As someone new to frontend development, I am aiming to have a header design similar to that of popular websites like StackOverflow or YouTube, where an image or icon is positioned just ...

Uploading SQL Files with the Help of jQuery and Ajax

I have encountered a rather trivial issue and cannot seem to find a suitable solution for it. It's quite basic, really. I am attempting to upload a file with a .sql extension through jQuery and AJAX using a Bootstrap modal in a WordPress plugin, but u ...

Transform the column's datetime into a date in the where condition when using sequelize

Hey there, I'm looking to convert a datetime column into just date format while running a query. Could someone assist me with creating a Sequelize query based on the example below? select * from ev_events where DATE(event_date) <= '2016-10- ...

jquery live condition problem not resolving

I am currently using jQuery. In a normal scenario, when I use $(document).ready, the rows and columns in the table are highlighted. However, when I retrieve data for the table using $.ajax({}), the highlighting does not occur. My code looks like this: $( ...

Unleashing the power of Vuex with promise chaining

One challenge I am facing is making API calls to retrieve an array of endpoints, which are then used to fetch data from another API. // Raise isLoading flag this.$store.commit('isLoading', true); // Initial data fetch this.$s ...

Is it possible to use both "npm install --global" and "--save" simultaneously?

I'm curious if it is practical to use both the --global and --save parameters in the npm install command simultaneously. For instance: npm install gulp -g -s From my understanding, since there is no package.json in the npm system folder, I assume th ...

What is the process for verifying that a checkbox is unchecked through the use of Ajax and PHP?

I am working with a checkbox element in my form. Here is the code: <input type="checkbox" value="yes" id="checkBox"> This checkbox is part of my form, and I am sending the form data to a PHP file using Ajax: var check = $('#checkBox').v ...

Unable to display Plotly chart in HTML using Python

I'm currently working on building a Python dashboard using Plotly for generating graphs and HTML for the user interface. Within my app.py file, I have defined the graph and then implemented the following code snippet: graph1Plot = plotly.offline.plo ...

What is the best way to eliminate a white border that appears only on my ThreeJS website when viewed on a mobile device?

I initially suspected a potential issue with resizing the window, so I created a JavaScript function to handle it. However, that did not resolve the problem. Any other ideas on how to troubleshoot this? // If the user resizes the window, update camera a ...

Having trouble incorporating Duo Web SDK into angular application

We are currently working on incorporating Duo Two-factor authentication into our Angular application. For instructions, you can take a look at the documentation available here. The issue we are encountering is that their JavaScript file searches for an i ...

jquery slider for inputting phone number on a mobile device

I am currently working on enhancing the user interface by implementing a feature where users can select a mobile number using a slider. The idea is that the user will choose a digit between 0 and 9 using the slider, then confirm their selection by pressing ...

Creating sitemaps on Next.js using next-sitemap is not supported

Creating dynamic sitemaps for my Next.js site using next-sitemap has hit a snag. Following the documentation, I've implemented the following code: //pages/server-sitemap-index.xml/index.js import axios from "axios"; import { getServerSideSi ...

Center div encroaching on floated left div

https://i.sstatic.net/uwyGY.pngCan someone help me align three divs horizontally? I'm having an issue where the center div is overlapping the left div. What could be causing this problem? <div> <div style={{width:"100px", ...

Using React to trigger a child component's function upon clicking a tab

I need assistance with creating a React app that includes two tabs (Tab1, Tab2). When Tab2 is clicked, I want a message to appear in the console saying 'Function A is called'. Unfortunately, the code I have currently does not display the message ...

What is the best way to collect and store data from various sources in an HTML interface to a Google Spreadsheet?

Currently, I have a spreadsheet with a button that is supposed to link to a function in my Google Apps Script called openInputDialog. The goal is for this button to open an HTML UI where users can input text into five fields. This input should then be adde ...

Utilizing jQuery to trigger animations when the form is hovered over or when the input box is

I am currently working on implementing opacity effects for an entire form when it is hovered over or when an input box is clicked while the mouse cursor has moved away from the hover area, ensuring that the effect remains visible. Here is the HTML code I ...

Update variables in jQuery when the window is resized

Seeking help from the jQuery experts as I am relatively new to it. I have managed to create a scrolling function that works well with dynamically generated content. I am facing an issue with resizing window and firing of resizeDiv and setScrollingPoints f ...

Obtain Rails database queries in real-time

Is it possible to retrieve database results dynamically in Rails? For instance, if I have a list of cities indexed by ID, can I pass the ID to the view based on the city name, similar to this JavaScript method (even though I know this code won't work) ...