Published: March 3, 2023
| Written by Scott Minnis
To create a circle background with a number centered vertically and horizontally in it and have the circle center-aligned on a WordPress website, you can use CSS flexbox and the text-align: center property. Here’s an example code snippet that you can use:
First, you’ll need to create the circle background. You can do this using CSS. Here’s an example code snippet that you can use:
You can adjust the width, height, and background color of the circle to your liking. The display:flex property turns the container and the circle into flex containers, and justify-content:center, align-items:center, and text-align:center center the contents both horizontally and vertically within the circle and the circle itself horizontally within its container.
Once you have your circle background, you can add the number inside it. You can do this by creating a shortcode in WordPress that will display the number. Here’s an example code snippet for the shortcode:
This shortcode will create a div with the class “circle-container” that centers the circle horizontally within it and a div with the class “circle” that centers the number both horizontally and vertically within the circle.
To use the shortcode on your WordPress website, simply add the following code to the post or page where you want the circle with the number to appear:
Replace “your-number-here” with the number that you want to display.And that’s it! You should now have a circle background with a number centered vertically and horizontally in it and a circle that is center-aligned on your WordPress website