-2

Bootstrap を使用して個人の Web ページを作成しています。グラデーションの背景を追加しようとし<body>ましたが、意味のないグラデーションのスペースになってしまいました。これが画像です。複数のCSSファイルがあるため、jsfiddleを含めることはできません。

http://jsfiddle.net/eJ3CL/

ブートストラップが含まれていないため、jsfiddle では問題を確認できませんが、スクリーンショットは次のとおりです。

編集:フィドルを 編集してブートストラップを含め、コンテンツの高さを120pxに設定して、OPが伝えたい問題を他の人が見ることができるようにしました。

コンテナの高さを 900 に設定すると

コンテナの高さを 500 に設定すると

これは何が原因ですか?この問題を解決するにはどうすればよいですか?

編集済み:関連するすべてのコードは次のとおりです。

<head>
    <title>Burak Özmen - A Newbie Designer</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <link href="css/reset.css" rel="stylesheet" type="text/css">
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="style.css" rel="stylesheet" type="text/css">

</head>
<body>
    <div class="container container-top">
        <div class="page-header">
            <h1>Burak Özmen <small>A Newbie Developer</small></h1>
        </div>
    </div>
    <div class="container container-middle">
        <div class="navbar navbar-static-top navbar-inverse">
            <div class="navbar-inner">
                <ul class="nav">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About Me</a></li>
                    <li><a href="#" class="pull-right">Link</a></li>
                </ul>
            </div>
        </div>
        <div class="vertical-middle">In development... </div>
    </div>
</body>
</html>

スタイル.css:

body {
background: rgb(249,252,247); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(249,252,247,1) 0%, rgba(245,249,240,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(249,252,247,1)), color-stop(100%,rgba(245,249,240,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f9fcf7', endColorstr='#f5f9f0',GradientType=0 ); /* IE6-9 */


}

.container-middle {
    height: 300px;
    background: white;

}
4

2 に答える 2

1

体に最小の高さを与える

body {
  min-height: 400px;
}
于 2013-04-20T21:39:58.330 に答える
0

body セレクターのルールを html セレクターに移動し、ルールをセレクターに追加height:100%;htmlます。

html{
background: rgb(249,252,247); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(249,252,247,1) 0%, rgba(245,249,240,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(249,252,247,1)), color-stop(100%,rgba(245,249,240,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(249,252,247,1) 0%,rgba(245,249,240,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f9fcf7', endColorstr='#f5f9f0',GradientType=0 ); /* IE6-9 */
height: 100%;

}

.container-middle {
    height: 300px;
    background: white;

}

Firefox、Chrome、IE9 で動作します

于 2013-04-20T21:33:38.920 に答える