-2

したがって、テキストをページの中央に配置したいと思います。また、ページの下部にあるテキストを中央に配置する別の div も必要です。

ここに私のCSSコードがあります

#header { text-align:center; color:white; font-family:'Capture'; font-size:34px; margin: auto; width: 800px;}
    #slogan { text-align:center }

    @font-face { font-family:'Capture'; src:url(/fonts/Capture_it.ttf); }
    .info-container { width: 840px; border: 1px solid #d8d5c6: padding: 4px; margin: 40px auto 0; }

    .inner-border { background-color: #fcfbf9; border: 1px solid #d8d5c6; padding: 10px 20px; }

    .coming-soon-visitor strong, .coming-soon-owner strong { font-weight: bold; color: #000; }

    .coming-soon-owner { float: left; font-size: 14px; color: #6d6a5b; font-weight: normal; width: 400px; border-right: 1px solid #d9d6c5; padding: 10px 0; margin-bottom: 10px; }

    .coming-soon-visitor { float: left; font-size: 14px; color: #6d6a5b; font-weight: normal; padding-left: 20px; padding: 10px 0 10px 20px; margin-bottom: 10px; }
4

2 に答える 2

1
<div style="text-align:center">Your text here</div>

そしてあなたのCSSのために

<div id="my-div">Your text here</div>

#my-div{ text-align: center }

「DIV を中央に配置したい」という場合は、次のようにする必要があります。

<div id="my-div">Your text here</div>

#my-div{ width: 800px; margin: 0 auto; text-align: center }

それを超えると、質問があいまいすぎて、求める答えが得られない可能性があります

于 2012-12-21T20:34:14.073 に答える
0

以下のコードが役立つかどうかを確認してください。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>align</title>
<style type="text/css">
body {
    margin: 0px;
    padding: 0px;
}
#text_center {
    text-align: center;
    width: 200px;
    position:absolute;
    left:50%;
    top:50%;
    margin-left:-100px;
    margin-top:-20px;
}
#text_bottom {
    text-align: center;
    width: 200px;
    position:absolute;
    left:50%;
    bottom:1%;
    margin-left:-100px;
}
</style>
</head>
<body>
    <div id="text_center">Text 1</div>
    <div id="text_bottom">Text 2</div>
</body>
</html>
于 2012-12-21T20:40:15.570 に答える