0

学校向けの PHP プロジェクトを行っています。ヘッダー ナビゲーション リストのテキストを中央に配置したいのですが、どちらもtext-align: center;機能しませんvertical-align: middle;。助言がありますか?

http://ectweb.cs.depaul.edu/AHARDEN2/project/index.php

4

3 に答える 3

1

style.css の 241 行目に width と margin:auto を追加します。nav と ul を参照する float をすべて削除します。

于 2012-07-10T15:59:17.143 に答える
0
body > nav {
    text-align: center;
}

body > nav > ul {
    display: inline-block;
    float: none;
}
于 2012-07-10T15:54:40.937 に答える
0

CSS では、通常、最善の方法は次のとおりです。

テキストの場合:

.centredText {
  margin-left: auto;
  margin-right: auto;
  width: 4em; /* This is whatever size you need each margin to be. */
}

divまたは画像の場合(これはどのように聞こえますか):

.centredItem {
  display: table;
  margin-left: auto;
  margin-right: auto;
}

次に、HTMLで、<div class="centredItem">Stuff</div>

于 2012-07-10T18:30:58.207 に答える