How to Center Text within a CSS-Drawn Circle?
Dec 07, 2024 am 02:01 AMHow to Draw a Circle with Text in the Center
To create a circle with text in the middle using CSS, modify the code used to draw the circle:
- Set line-height to match the height of the div. This forces a single line of text to appear vertically centered. In the example below, the height and line-height are both set to 500px.
.circle { width: 500px; height: 500px; line-height: 500px; border-radius: 50%; font-size: 50px; color: #fff; text-align: center; background: #000 }
- Add text to the div. Wrap the desired text within the <div> element.
<div class="circle">Hello I am A Circle</div>
This code will create a centered circle with the text "Hello I am A Circle" positioned in the middle.
The above is the detailed content of How to Center Text within a CSS-Drawn Circle?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Adding Box Shadows to WordPress Blocks and Elements

Create a JavaScript Contact Form With the Smart Forms Framework

Making Your First Custom Svelte Transition

Demystifying Screen Readers: Accessible Forms & Best Practices

Comparing the 5 Best PHP Form Builders (And 3 Free Scripts)
