Center Content In Div?

Discussion in 'CSS' started by gobbly2100, Aug 30, 2007.

  1. #1
    How do I center my JavaScript in a div?

    Thanks!
     
    gobbly2100, Aug 30, 2007 IP
  2. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <div align="center"></div>
    Code (markup):
    That's the idea basically. Although you can use the same code in your css if you have any class/div applied to the div.

    just add this to the css:
    align:center;
    Code (markup):
    Remember, this will allow for Horizontal centering only.
     
    GWiz, Aug 30, 2007 IP
  3. gobbly2100

    gobbly2100 Banned

    Messages:
    906
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I tried that but apparently it is not a valid attribute, I put "align:center;" in my CSS but that does not work.

    Are there any other attributes to try?
     
    gobbly2100, Aug 30, 2007 IP
  4. DominoBB

    DominoBB Peon

    Messages:
    48
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try:
    <div style="text-align: center;"></div>
     
    DominoBB, Aug 30, 2007 IP
  5. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If the above code doesn't solve your problem, I'd suggest you post your html/css here so we can get a better understanding of what you're trying to accomplish.
     
    GWiz, Aug 30, 2007 IP
  6. vasildb

    vasildb Well-Known Member

    Messages:
    845
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #6
    I think <center></center> will work.
     
    vasildb, Aug 30, 2007 IP
  7. gobbly2100

    gobbly2100 Banned

    Messages:
    906
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I was being a bit of a noob, I had the div not set to the full page width so I needed to just make both margins auto.

    Thanks for the replies still though guys.
     
    gobbly2100, Aug 30, 2007 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #8
    align="center" on a DIV?!? (not even valid HTML)
    align:center in CSS? (Not a valid CSS propery)

    I almost spit up my soda when I saw those - then:

    CENTER TAGS?!?

    Good lord, what is this 1997?

    Glad you found the CORRECT answer there gobbly - margin:0 auto;
     
    deathshadow, Aug 30, 2007 IP
  9. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #9
    hahah deathshadow. Now you know how it feels to get screwed with. :)
     
    GWiz, Aug 30, 2007 IP
  10. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Oh, he's known for a while.
     
    Dan Schulz, Aug 31, 2007 IP