Jump to content
RenCorner Network

How do I center this?


Evo
 Share

Recommended Posts

So I did an animation were whenever a mouse goes over the variable myName, (which is made out of squares) they all disperse with a cool animation. I was wondering if I wanted to use this on a website, how could I center it? Or use it after all my content (at the bottom of my page)

Thanks in advance

Something weird happened. Try this link http://pastebin.com/UgN0KAMj

Beware most of it is just walls of text of the Javascripts used so I can run it off of my computer locally, and not have to grab them from the web. The important part starts at line 20/

Edited by DrSithis
Merged post so the working Pastebin link was on the first post
Link to comment
Share on other sites

Why wouldn't you make it so that the fucking HTML file isn't so large and do a javascript include? That's a bunch of useless crap that isn't needed on a webpage. It'll take a while to load the webpage, not only that you also have to think about the fact that how many people are actually going to see this? lol

  • Like 1
Link to comment
Share on other sites

As I just stated you'll get more help IF YOU do as I said above. No one can read that mess.

 

Additionally you could properly write a better piece of javascript for that. -_-

Link to comment
Share on other sites

Please don't tell me you have that javascript code on every html page you use. Actually, as far as I can tell you've included a bunch of different scripts in your html which is the most ridiculous thing I've ever seen; think of the cache, parallelism, etc.

 

As far as I can tell, you want to center something, please actually google before asking a new question: http://stackoverflow.com/questions/14883805/simple-center-a-object-with-css-and-no-hacks

 

If I haven't answered your question then clean up your code, use links that work and say explicitly what you want to know.

  • Like 1
Link to comment
Share on other sites

Not sure what you are trying to do here. You have the script in the wrong place. Most of that should be includes not in the document. Also there is no point in the footer tag. And you have nothing in the body of the webpage.

  • Like 2
Link to comment
Share on other sites

Not sure what you are trying to do here. You have the script in the wrong place. Most of that should be includes not in the document. Also there is no point in the footer tag. And you have nothing in the body of the webpage.

 

The script is there for a temporary project. I was just wondering about the footer, and I'm going to add things in the body....

Link to comment
Share on other sites

The script is there for a temporary project. I was just wondering about the footer, and I'm going to add things in the body....

And this project is a waste of time. Why can't you use google as BillieJoe67 said? Most of what you want answered is already answered online. Not only that but again, you should get some proper code done instead of having all that bullshit. No one is going to help you if something is 200+ lines. There are scripts out there, I shit you not, that do the same function you want and they are under 20 lines.

 

Not only that but, you need to reconsider doing it all entirely. I'd write it up again for you but you are more than capable of doing it. Fix it up.

Link to comment
Share on other sites

I'm sorry.... As you can tell I'm not very good at this, that's why I asked for help.... I'm sorry....

 

I'll have this in main.js

var red = [0, 100, 63];var orange = [40, 100, 60];var green = [75, 100, 40];var blue = [196, 77, 55];var purple = [280, 50, 60];var myName = "Kyle Lindgren";var letterColors = [red, orange, green, blue, purple]if(420 > 69) {    bubbleShape = "circle";}else {    bubbleShape = "square";}drawName(myName, black);bounceBubbles()

And this as my Index.html

<!DOCTYPE html><html>  <head>    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>    <script type="text/javascript" src="bit.ly/1dAojeQ"></script>  </head>  <body>    <canvas id="myCanvas"></canvas>    <script type="text/javascript" src="bit.ly/1dAojeQ"></script>    <script type="text/javascript" src="main.js"></script>  </body></html>

Did I do that correctly?

  • Like 1
Link to comment
Share on other sites

You should use the full url for those scripts (http://code.jquery.etc) and the last two script tags should be moved into the head section with the others. I would suggest that you look into the ready handler and make the calls to drawName and bounceBubbles in there so that it only happens once the browser has loaded everything.

 

Finally I wouldn't use shortened links in the actual code as you still won't use the browser cache effectively.

I suggest you make a jsfiddle with basic working code, then we can help you improve/develop your idea more effectively

Link to comment
Share on other sites

Yea I am not sure what you are doing in the body there. If you want help tell us what you are trying to do. Right now it isn't going to show anything on the webpage. 

Link to comment
Share on other sites

When I copy-paste, I at least try to understand how the herpderp code works (actually, I just don't copy-paste).

 I was feeling generous so I decided to write a working jsfiddle for this code. Upon googling code from bubbles.js I found this and this.

 

If you want to (slightly) redeem yourself, google centering a canvas and see if you can work it out.

 

tl;dr op stole code, claimed it was his, can't edit it

  • Like 1
Link to comment
Share on other sites

When I copy-paste, I at least try to understand how the herpderp code works (actually, I just don't copy-paste).

 I was feeling generous so I decided to write a working jsfiddle for this code. Upon googling code from bubbles.js I found this and this.

 

If you want to (slightly) redeem yourself, google centering a canvas and see if you can work it out.

 

tl;dr op stole code, claimed it was his, can't edit it

I did a thing on codecademy, and wanted to use it for something else, that's why I was wondering how I could

Link to comment
Share on other sites

You realise you can see exactly who wrote codeacademy articles? You are definitely not Lalith Polepeddi so please just give up pretending you wrote it from scratch.

 

This this works - I've tried it. If you have any sensible questions, I might be able to help you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...