Styled CSS circle with a partially filled border color and a numerical value enclosed within

I want to create a unique design for a circle with a centered number and partially colored border like this:

https://i.sstatic.net/rOzWA.png

My goal is to highlight the circle based on a number ranging from 0-100.

Here is my current code for creating the circle:

#circle {
        border-color: lightgray;
        border-radius: 50%;
        border-style: solid;
        border-width: 5px;
        box-sizing: border-box;
        height: 100px;
        position: relative;
        width: 100px;
    }

<div id="circle">
   37
</div>

However, I am struggling to dynamically change the border color based on the number and center the text within the circle.

Here's what it looks like currently: https://i.sstatic.net/3bD1J.png

Answer №1

This resource can assist you in changing the background color by visiting this website and creating gradients according to your requirements. If you have any further questions, feel free to ask.

<!DOCTYPE html>
<html>
<head>

    <title>Border</title>
    <style>
        .outer_circle {
            position: relative;
            margin: 50px;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: #ffffff;
            display: flex;
        justify-content: center;
        place-items: center;
        font-size: 30px;
        font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
        }
          
        .inner_circle {
            background-image: linear-gradient(
                     to bottom, rgb(9, 112, 26) 0%,
                     rgb(21, 255, 0) 100%);
            content: '';
            position: absolute;
            top: -10px;
            bottom: -10px;
            right: -10px;
            left: -10px;
            z-index: -1;
            border-radius: inherit;
          
        }
    </style>
</head>
<body>

     <div class="outer_circle"> 37
        <div class="inner_circle"></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

What could be causing the slight imperfection in the alignment of this CSS checkbox slider switch?

This unique CSS slider switch has different rendering outcomes based on the resolution: It is pixel-perfect on a laptop display with a resolution of around 1400 x 800. However, it is not pixel-perfect on a 1920 x 1080 display with Windows 10's "Scale ...

Adding a row from two drop-down lists to a table and deleting it upon selection

Looking to dynamically update a table based on dropdown selection in jQuery. When a value is selected from the first dropdown list (projects), followed by a selection from the second dropdown list (employee), the selected values should be added as a new ro ...

Retrieve text from a dropdown menu while excluding any numerical values with the help of jQuery

I am currently implementing a Bootstrap dropdown menu along with jQuery to update the default <span class="selected">All</span> with the text of the selected item by the user. However, my objective is to display only the text of the selected it ...

Can I leverage Bootstrap's 5 grid system exclusively?

Previous iterations of Bootstrap allowed for the creation of custom setups, specifically focusing on the grid system. Is it possible to craft a tailored Bootstrap 5 configuration that exclusively includes support for the grid system? ...

What's the best way to ensure that Bootstrap columns have consistent height with space in between?

Looking to create three columns of equal height in Bootstrap, with no gaps between them? Check out this screenshot for reference: Screenshot Below is the code snippet you can use: <div class="container"> <div class="row mt-4&qu ...

Adding multiple checkboxes to a single database field

Looking for a way to insert multiple checkbox values into one database field in a comma delimited format. For example, if the user selects checkbox one and checkbox two, I want the database input to be "tickOne, tickTwo, etc." Does anyone have suggestions ...

To include a slash or not before the assets path in HTML - that is the question

Should the use of / in front of paths in HTML pages be considered a good practice? If using / for paths, is it necessary to configure a <base url=""> in the page? An issue arises with a generated CSS file that includes the following: background-ima ...

I am encountering difficulties retrieving all image attributes with Beautiful Soup and Selenium

When using soup.select('img[data-image-large]'), I am having trouble extracting just the src image from data-image-large. The output contains multiple img elements with various attributes: [<img alt="Adidas Originals NMD C2" class="img-respon ...

The issue of misaligned display of HTML and CSS rectangles

Greetings! I've got a website that contains some informative text for users. To enhance its visibility, I'm looking to add a white rectangle as a background behind the text. Although I can successfully draw the rectangle, it appears over the tex ...

When selecting an option, the radio button becomes unresponsive and locked in

Currently, I am tackling an Angular project and have created an application that must be compatible with iPad. The issue lies with the radio button - whenever it is clicked, it freezes/disables in Safari but works perfectly fine in other browsers like Ch ...

"Exploring the Issue of Undefined Materialize CSS Text Area When Used as an Object

There is a sidebar within a Google Sheet that runs an HTML file calling Materialize CSS. The sidebar contains three text inputs that work fine, but there is one text area that keeps failing. I am wondering if anyone has any thoughts on this issue. Here is ...

Using JavaScript to open a new window and display CSS while it loads

I am looking to utilize a new window for printing a portion of HTML content. var cssLink = document.getElementByTagName('link')[2]; var prtContent = document.getElementById('print_body'); var WinPrint = window.open(' ...

Using PHP DOM document, extract the menu array from an HTML string

Below is the snippet of code I am working with: $string = '<html><head></head><body><ul id="mainmenu"> <li id="1"><a href="1"> main menu 1 </a> </li> <li id="2"> <a href="2"> main ...

Instructions on making one script activate another [jQuery] for resizing and enlarging a search box

Hi there, I'm facing a small dilemma and would appreciate some guidance. I've been working on creating a menu bar that mimics the functionality of apple.com (where the search bar expands when clicked to show options). Currently, I have a script ...

Verify the status of the nested reactive forms to determine if the child form is in a dirty state

I am working on a form that consists of multiple sections within nested form groups. I need to find a way to detect when changes are made in a specific section. Here is the HTML structure: <div [formGroup]="formGroup"> <div formGroupN ...

Navigational inconsistency with SVG icons integrated into Bootstrap Navbar

Bootstrap offers icons in embedded SVG format. These SVG tags can be directly added to HTML code. However, when I included the SVG tag in my navbar, the icon did not appear centered even after using the vertical-align: middle CSS property. The icon did not ...

The WebView component is unable to display internally stored CSS files within the project

Looking to display HTML content with CSS styling stored in a file downloaded from a URL and saved within the "context.filesDir". The downloaded folder contains all the assets required by the CSS file. Despite passing the CSS file path to the webv ...

What is the best way to retrieve data from ng-controller to use in the 'src' attribute of an <img> tag?

Check out this snippet of HTML: <div data-ng-controller="sampleCtrl" > <ul data-ng-repeat="item in sampleData"> <li class="message"> <img src="img-source" width="30" height="30"> <div class="message-text"> ...

Create a new div element called "aside" and place it within the existing div

After searching on SO, I couldn't find the same question anywhere. .container { display: flex; justify-content: center; } .aside-left { width: 200px; } <div class="container"> <aside class="aside-left"> menu1 menu2 </a ...

Is there a way to modify just the homepage url of the logo on a WordPress website using the OceanWP theme?

My website, abc.com, is set up with Angular for the homepage and WordPress for the blogs. The WordPress site is located in a subfolder within abc.com. You can see the file structure in the image below. I am now looking to change only the homepage link on ...