javascript - How can i build a circular dialog using css/html -


im building mobile app using html/css display list of contacts. want display shortcut call/email on lines of attached screenshot. thoughts on how css/html ? have tried couple of changes js callbacks havent been represent pop over.enter image description here

after making changes answer on positioning divs in circle, how can it.

the idea position divs in circle using trigonometry , javascript.

fiddle

the function generate(n, r, id) takes 3 arguments: n - number of divs, r - radius , id - main in our case. if intend change variable r other 100, need change variable adjust make align properly.

html:

<div id="main"></div> 

javascript:

var theta = [];  var setup = function (n, r, id) {     var main = document.getelementbyid(id);     main.style.width = r * 2 + 'px';     main.style.height = r * 2 + 'px';     var adjust = 4.8;     var mainheight = parseint(window.getcomputedstyle(main).height.slice(0, -2));     var circlearray = [];     (var = 0; < n; i++) {         var circle = document.createelement('div');         circle.classname = 'circle number' + i;         circlearray.push(circle);         circlearray[i].posx = math.round(r * (math.cos(theta[i]))) + 'px';         circlearray[i].posy = math.round(r * (math.sin(theta[i]))) + 'px';         circlearray[i].style.position = "absolute";         circlearray[i].style.backgroundcolor = 'black';         circlearray[i].style.top = ((mainheight / 2 - (n * adjust)) - parseint(circlearray[i].posy.slice(0, -2))) + 'px';         circlearray[i].style.left = ((mainheight/ 2 - (n * adjust)) + parseint(circlearray[i].posx.slice(0, -2))) + 'px';         main.appendchild(circlearray[i]);     } };  var generate = function(n, r, id) {     var frags = 360 / n;     (var = 0; <= n; i++) {         theta.push((frags / 180) * * math.pi);     }     setup(n, r, id) } generate(4, 100, 'main'); 

css:

div {     box-sizing: border-box; }  div#main {     height: 100px;     width: 100px;     position: absolute;     left: 5%;     top: 5%;     transform: rotate(45deg);     border: 1px solid black;     border-radius: 100px; }  div.circle {     position: absolute;     width: 20px;     height: 20px;     border: 2px solid black;     border-radius: 10px;     -webkit-border-radius: 10px;     -moz-border-radius: 10px; } 

let me know if need make further change


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -