Skip to main content
Known Participant
June 11, 2017
Answered

Centering an Animate project in Dreamweaver

  • June 11, 2017
  • 2 replies
  • 818 views

Hi,

I am completely lost with this one.  I created a project in Animate, published it, and have imported it into Dreamweaver.  All I want to do is center it horizontally in Dreamweaver.  I've tried using the following CSS  (margin: 0, auto;) to no avail.

Here is the test page.

http://taffyproductions.com/test/

Thanks in advance.

Gary

This topic has been closed for replies.
Correct answer osgood_

Add margin: 0 auto; display: block; to the <canvas> tag like below:

<canvas id="canvas" width="960" height="200" style="background-color:#000000; margin: 0 auto; display: block;"></canvas>

or move all the attributes to a css selector:

#canvas {

background-color: #000000;

margin: 0 auto;

display: block;

}

<canvas id="canvas" width="960" height="200"></canvas>

2 replies

Niharika Jha
Adobe Employee
Adobe Employee
June 12, 2017

Hi,

I have centered an Animate object on my page using CSS on a section tag, please refer snapshot. I can share you my css file that I used. Please see if it helps.

Regards,

Niharika Gupta

Adobe Dreamweaver.

TaffyproAuthor
Known Participant
June 12, 2017

Hi Nikarika,

Yes please share the CSS you used.  Thank you

osgood_Correct answer
Legend
June 12, 2017

Add margin: 0 auto; display: block; to the <canvas> tag like below:

<canvas id="canvas" width="960" height="200" style="background-color:#000000; margin: 0 auto; display: block;"></canvas>

or move all the attributes to a css selector:

#canvas {

background-color: #000000;

margin: 0 auto;

display: block;

}

<canvas id="canvas" width="960" height="200"></canvas>

Nancy OShea
Community Expert
Community Expert
June 11, 2017

I don't work with Animate stuff much.  But try this CSS in your page and see if it helps.

* { box-sizing:border-box }

canvas {width: 80%; margin-left: 10%; margin-right: 10%}

Nancy

Nancy O'Shea— Product User & Community Expert
TaffyproAuthor
Known Participant
June 11, 2017

Hi Nancy,

Thank you for the quick response.  When you bring a published Animate project code into DW it generates the following code for the Body tag.  It is written slightly different than the CSS I am used to seeing 9in a style sheet).  I want to put it all in one div because the rest of the site will be centered as well.

Any ideas?

You rock!

<body onload="init();" style="background-color:#D4D4D4;margin:0px;">

    <canvas id="canvas" width="960" height="220" style="background-color:#000000"></canvas>

</body>

Nancy OShea
Community Expert
Community Expert
June 11, 2017

Canvas is a separate element and that's where your animation is located.

If you want a centered <body>, do as you always have.  Give  it a width and margin: 0 auto.

Nancy

Nancy O'Shea— Product User & Community Expert