Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to arrange the elements of a semicircle in css/html/js

i seem to be lost how to mark up phrases list (named title1, title2, title3, etc on the attached image) in semicircle form. Maybe there is easy css crossbrowser solution (no-no, no IE6, ha-ha), or i need to use javascript? I can't insert it as image, because i have a requirement that all text on the page should be real text.

Or maybe there is some Jquery plugins that could solve such issue..

example

Thanks in advance!

like image 593
avasin Avatar asked Jun 04 '12 23:06

avasin


People also ask

How do you make a semi semicircle in CSS?

You could use border-top-left-radius and border-top-right-radius properties to round the corners on the box according to the box's height (and added borders). Then add a border to top/right/left sides of the box to achieve the effect.

How do you write text in a semicircle in HTML?

The box and half circle can be created with a div tag. The circle can be clipped to show the left part only. The text letters can be rotated.

How do you make a half circle in a div?

A Semi-Circle or a Half-Circle shape can be easily created using HTML and CSS. We will use the border-radius property to draw the desired output. HTML Code: In this section we will create a simple “div” element using the <div> tag.


1 Answers

I would use JavaScript and some simple math to calculate the position of each title. The formula for the x and y position on a circle is the following:

x = radius * cos( angle )
y = radius * sin( angle )

So using this, you can calculate the position of each title:

elem.style.left = radius * Math.cos( angle ) + "px"; // angle in radians
elem.style.top = radius * Math.sin( angle ) + "px";

I have made a demo fiddle showing this: http://jsfiddle.net/eGhPg/

like image 166
Will Avatar answered Oct 20 '22 18:10

Will