CCC
CCC

Reputation: 49

How do I center a script?

The code I am having issues with is http://jsbin.com/ESOdELU/1/edit

I'm in the early process of learning Javascript and my last question was answered very well and I got the perfect script (linked above) for what I am trying to do but everytime I try and add things to the script it messes up so I clearly do not know what I am doing.

I now want to centrally align the script and I want to do a line break between a button and the data the button generates once pressed.

The code is currently between and and when I try and add code to align the script inside it doesn't work. When I try outside (I searched online and saw about using div align but that doesn't work for me either unfortunately).

For the line break I want to be able to have the button on the top line and on the bottom line I want the data to be displayed once the button has been pressed.

Upvotes: 0

Views: 54

Answers (1)

Cfreak
Cfreak

Reputation: 19319

Create a div and center it:

<div style="margin:0 auto;" id="someid"></div>

Then the last line of your Javascript where it says

wordRandomizer.run(document.body);

You can reference any element you want. In this case you would change it to:

wordRandomizer.run(document.getElementById("#someid"));

Upvotes: 1

Related Questions