SitePoint Sponsor

User Tag List

Results 1 to 18 of 18

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamically create and position button: center/bottom

    Hi,

    I'm trying to dynamically create a basic button (to launch an action onclick) on a page that has a centered 640X640 canvas. The page is set up as 750X750. The button would need tobe at center bottom below the canvas (can be 20 px below, for example).

    So far, using the following, I can get it to work OK. But done by "trial and error." Not sure as beginner what would be the correct way to accomplish this, since need to also place additional buttons dynamically on this and other similar pages.

    Any help appreciated.

    Code:
    //HTML
    <button name="start" type="button" onclick="starter()"
    style="background-color:white;">
    start</button>
    
    //CSS
    canvas{
        border:1px solid black;
    	position: absolute;
      	top: 50%;
      	left: 50%;
      	margin-left: -320px;
      	margin-top: -320px;
    }
    button{
       	position:absolute; 
       	margin-left:47%;   
       	width:150px;
       	bottom:280px;
    }
    Thank you for your help.

    Kind Regards,

    writer1
    Last edited by ralph.m; Jul 22, 2013 at 07:11.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •