admin管理员组

文章数量:1392076

<!doctype html>
<html>
    <head>
        <title>Main</title>
        <style>
          #titlePic {
            text-align: center;
          }
          #3dCanvas {
            text-align: center;
          }
          #difficulties {
            text-align: center;
          }
        </style>
    </head>
        <body>
            <div id='titlePic'>
            <h1>
                <img src="../IndividualProject/images/SHIFT_PROMO.png" alt="SHIFT_PROMO" width="512" height="250"/>
            </h1>
            </div>
        <div id='3dCanvas'>
                <script src='./Scripts/three.min.js'></script>
                <script src='./Scripts/threex.text.js'></script>
                <script src="./Scripts/droid_serif_bold.typeface.js"></script>
                <script src='./Scripts/3dText.js'></script>
                </div>
            <div id='difficulties'>
                <h2>
                <a href="index.html"><img src="../IndividualProject/images/Marathon.png" alt="Marathon" width="321" height="54" /></a>
                <br><br>
                <a href="index.html"><img src="../IndividualProject/images/Easy.png" alt="Easy" width="164" height="48" /></a>
                <br><br>    
                <a href="index.html"><img src="../IndividualProject/images/Medium.png" alt="Medium" width="225" height="48" /></a>
                <br><br>
                <a href="index.html"><img src="../IndividualProject/images/Hard.png" alt="Hard" width="162" height="48" /></a>
                <br><br>
                </h2>
            </div>
    </body>
</html>

Im trying to move this 3D animated text to the center of the HTML page but nothing seems to work, any help?

The JavaScript files are located in 3dCanvas, text align seems to do nothing

here is a codepen

<!doctype html>
<html>
    <head>
        <title>Main</title>
        <style>
          #titlePic {
            text-align: center;
          }
          #3dCanvas {
            text-align: center;
          }
          #difficulties {
            text-align: center;
          }
        </style>
    </head>
        <body>
            <div id='titlePic'>
            <h1>
                <img src="../IndividualProject/images/SHIFT_PROMO.png" alt="SHIFT_PROMO" width="512" height="250"/>
            </h1>
            </div>
        <div id='3dCanvas'>
                <script src='./Scripts/three.min.js'></script>
                <script src='./Scripts/threex.text.js'></script>
                <script src="./Scripts/droid_serif_bold.typeface.js"></script>
                <script src='./Scripts/3dText.js'></script>
                </div>
            <div id='difficulties'>
                <h2>
                <a href="index.html"><img src="../IndividualProject/images/Marathon.png" alt="Marathon" width="321" height="54" /></a>
                <br><br>
                <a href="index.html"><img src="../IndividualProject/images/Easy.png" alt="Easy" width="164" height="48" /></a>
                <br><br>    
                <a href="index.html"><img src="../IndividualProject/images/Medium.png" alt="Medium" width="225" height="48" /></a>
                <br><br>
                <a href="index.html"><img src="../IndividualProject/images/Hard.png" alt="Hard" width="162" height="48" /></a>
                <br><br>
                </h2>
            </div>
    </body>
</html>

Im trying to move this 3D animated text to the center of the HTML page but nothing seems to work, any help?

The JavaScript files are located in 3dCanvas, text align seems to do nothing

http://codepen.io/anon/pen/RNVwop here is a codepen

Share Improve this question edited Jan 17, 2015 at 21:04 Gan 1641 gold badge4 silver badges13 bronze badges asked Jan 17, 2015 at 19:52 TeaAnyOneTeaAnyOne 4973 gold badges9 silver badges16 bronze badges 2
  • can you recreate this in a fiddle or something? – jmore009 Commented Jan 17, 2015 at 19:57
  • codepen.io/anon/pen/RNVwop here is a codepen – TeaAnyOne Commented Jan 17, 2015 at 20:11
Add a ment  | 

1 Answer 1

Reset to default 3

You need just

body { text-align: center; }

or

canvas { margin: 0 auto; display: block;}

I didn't figured out who does create canvas: it seems it will be better to edit that script to make a wrapper around canvas, so it will be able to write better css

本文标签: Center align a JavaScript script on a HTML pageStack Overflow