-1

このフィドルにメニュー ナビゲーションを含めるためにコンテンツ div が拡張されるのはなぜですか? http://jsfiddle.net/kePCS/

nav の float プロパティを削除しても削除されません。ナビゲーションの幅が 100% に設定されているため、調べてみるとまだ同じサイズのようです。

私はそれを浮かせなければなりません。http://matthewjamestaylor.com/blog/beautiful-css-centered-menus-no-hacks-full-cross-browser-supportを使用しているのは、このメニューの不可欠な部分です。

しかし、下にあるはずのコンテンツの上にナビゲーションを配置したくありません。回避策を知っていますか?なぜこれが起こるのかについての説明も気にしません。どちらも幅100%なので重ならないだろうと思いました。明らかに私は間違っていました。ありがとう!

コードなしで投稿することはできませんが、フィドルの方が理解しやすくなります。

#menu {
float:left;
width:100%;
}
#content{
width:100%;
background-color:#5FC0CE;
}​
4

1 に答える 1

1

Floating the content will work, but I personally wouldn't. This is because floating tends to be the source of many IE bugs, and has some more subtle implications that might come back to bite you later.

There's not necessarily a right or wrong way to do this; however, I would instead add a "clear:both;" to #content, which will prevent it from bleeding up into the nav.

于 2012-12-04T16:35:48.697 に答える