Using CSS to encompass a group of words within a circular shape

I am attempting to encircle multiple words within one circle, but currently each word is enclosed in its own circle. Below is the code I am currently using.

HTML
<div class="numberCircle">
    <span>Circle all words</span>
</div>

CSS
.numberCircle {
    display: inline-block;
    line-height: 0px;
    
    border-radius: 50%;
    border: 2px solid;
    
    font-size: 32px;
}

.numberCircle span {
    display: inline-block;
    
    padding-top: 50%;
    padding-bottom: 50%;
    
    margin-left: 8px;
    margin-right: 8px;
}

Answer №1

You currently have two "span" tags in your markup, one with a class and one without. To avoid redundancy, delete the tag without the class and add the CSS styles to the remaining tag:

<span class="class"> words </span>

For adding multiple words within this class, use the following structure:

<span class="class"> <div> word 1</div>  <div> word 2</div> <div> word 3</div></span>

This will ensure all divs within the span have the same class for consistency in styling.

Answer №2

To easily achieve a circular number design, simply wrap your text with an element and apply the .numberCircle class to that element.

HTML

<div class="numberCircle">
    <span>Circle</span>
    <span>around</span>
    <span>text</span>
</div>

CSS

.numberCircle {
    display: inline-block;
    line-height: 0px;
    border-radius: 50%;
    border: 2px solid;
    padding: 20px; /* Add spacing around the edges */
    font-size: 32px;
}

.numberCircle span {
    display: inline-block;
    padding: 50% 0; 
    /* No need for margins in this case */
}

Check out an example of this in action here: https://jsbin.com/hekehatabu/1/edit?html,css,output

Answer №3

To encircle specific words, place them within a DIV element with the class numberCircle.

 <div class="numberCircle">
    <div>Highlight</div>
    <div>the</div>
    <div>desired</div>
 </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

Enhancing the appearance of the bootstrap fixed navbar with additional elements above and below

I am attempting to include a banner above my fixed-top navbar. Although I have some basic understanding of how to achieve this, my specific example seems to be more complex and I am struggling to find the right solution. Users should be able to add a cust ...

Steer clear of downloading images while on your smartphone

As I develop a responsive website, I encounter the challenge of optimizing image loading based on viewport size. While using CSS to hide images not needed for certain viewports can reduce display clutter, it does not prevent those images from being downloa ...

"Clicking on a child link within a Bootstrap5 dropdown causes the dropdown menu

I integrated a dropdown feature to create a navigation menu. The issue I encountered is that when I expand a heading and click on a sublink, the menu collapses instead of redirecting me to the intended link. I suspect this has something to do with the co ...

Angular 2+ with Customized Styles for Different Users

I'm facing a scenario where I need to apply different styles based on the clients/users accessing the site. Since all clients will be visiting the same site, I'll have to dynamically load styles based on the client that has logged in. What is t ...

What are the choices for the active element in a bootstrap navbar?

Is there a way to highlight the active element in bootstrap 4? Right now, Home is the active element, but it doesn't stand out enough. https://i.sstatic.net/5tKBx.png <li class="nav navbar-nav "> <a class="nav-link {{ Request::is(&apos ...

Tips for Creating an Upward-Dropping Dropdown Menu in HTML/JavaScript When Space is Limited on the Page

Hello, I am currently seeking a solution to adjust my dropdown menu so that it appears above instead of below when the page doesn't have enough space to display it fully. My tools for this project include HTML, Javascript, CSS, and JQuery exclusively. ...

Ways to modify the gap between buttons using CSS

I am faced with a design challenge on my home page. I want to add some spacing between the buttons so they are not too close to each other, but for some reason margin-top and margin-bottom properties are not working as expected. Can you help me figure out ...

The hover effects in CSS3 create unexpected interactions with surrounding elements in Chrome

Recently, I added a CSS3 hover effect to one of the images on my website following this tutorial: http://tympanus.net/Tutorials/OriginalHoverEffects/index2.html However, after implementing the hover effect in Chrome, I noticed that some other elements on ...

Turn the flipcard hover effect into an onclick action

After successfully creating interactive flip cards using CSS hover effects, I am now faced with the challenge of adapting them for mobile devices. I'm struggling to figure out how to translate my hover effects into onclick events for a mobile-friendl ...

The button on the Cookie Policy navigation window is no longer operational on the ASP.NET Core MVC website utilizing Bootstrap version 4.3.1

After integrating Bootstrap 4 into my ASP MVC Core web project and converting some HTML code to a Cookie Policy window, I noticed that the accept button is no longer functioning. Although the button is visible and clickable, it does not respond. In additi ...

Filtering HTML with HtmlAgilityPack using custom queries

I am faced with a block of two HTML elements in this format: <div class="a-row"> <a class="a-size-small a-link-normal a-text-normal" href="/Chemical-Guys-CWS-107-Extreme-Synthetic/dp/B003U4P3U0/ref=sr_1_1_sns?s=automotive&amp;ie=UTF8& ...

Ajax: The requested resource does not have the 'Access-Control-Allow-Origin' header. As a result, access is not permitted from origin 'null'

I recently started learning about ajax and followed a tutorial. However, I encountered an error when trying to run an HTML file along with a linked JavaScript file. Since browsers cannot make requests to file://, I have set up an http-server on port 8080 ...

Adding data to the SharePoint RichText Control using the WinForms WebBrowser Control

I am struggling to modify the content of an SP Rich Text field using the WinForms web browser control. While changing the values of other controls is straightforward, I have encountered difficulties with Rich Text fields. I found some suggestions on this b ...

Change the <base> element programmatically during server-side rendering

Searching for a way to obtain the base URL for an HTML page, so that relative URL requests from the browser utilize that base. If you are looking for answers, check out this link: Defining root of HTML in a folder within the site root folder When serving ...

How to set DIVS to be hidden when the page first loads

I am currently working on a project where I need to use JavaScript to hide certain <div> elements when the page loads. I have also included jQuery in my code. Below is what I have tried so far: $(document).ready(function() { hide(); function hid ...

Updating the navigation with a dynamic CSS class using jQuery

Hey there, I'm on the lookout for a simple and discreet method to dynamically add an "active" class to a navigation menu based on the current directory. Unfortunately, I am unable to modify the body tag with a custom class, ruling out a pure CSS solut ...

The deletion feature on my virtual keyboard was malfunctioning when using JavaScript

The virtual keyboard feature I added to my website isn't working properly, specifically the delete function. How can I fix this issue? Below is my code: HTML Code <input type="text" maxlength="12" min="10" name="msidn" id="jkeyboard" min="1" sty ...

Ways to deselect checkboxes and eliminate validation requirements

Below is the HTML code snippet that I am working with: <div class="form-group"> <div class="input-group"> <label for="daterange-vacancy" class="input-group-addon">Van</label> ...

Experiencing a problem with Datatables where all columns are being grouped together in a single row

After creating a table with one row using colspan and adding my data to the next row, I encountered an issue with the datatables library. An error message appeared in the console: Uncaught TypeError: Cannot set property '_DT_CellIndex' of unde ...

Flameflare/Console-inspired hover animation

Curious if there is a creative solution to this problem that I haven't thought of yet... I'm working on a site editor tool and it would be incredibly useful to have the ability to highlight elements when hovering over their code in the html/elem ...