2016-06-15 19 views
0

私はCSSでは最善ではなく、何が間違っているのか理解できません。私がサイドバーで使っている
タグかもしれないと思う。私はnav要素を "vert" idと "text-container" idを持つdiv要素をお互いにNEXTにしたいと思いますが、それは "text-container"の中に自分のものを送りますフッターは受け入れられません。2つのCSS要素が互いに隣り合うようにすることはできません

私はお互いを隣り合わせにするのは困惑しています。私は要素が相互に隣り合っていることが分かっています。これは、nav要素で "hor" idとすべてのa要素を問題なく使用していたためです。

私はそれが
タグかもしれないと思いますが、私はそれについて何ができるか分かりません。私はすでにヘッダーにそれを持っているので、私はちょうどnavbarを斧ることができましたが、私はそれを殺すためにナビバーに多くの時間を費やしました。

<html> 
    <head> 
    <title> The Resorts </title> 
    <link rel="stylesheet" type="text/css" href="./main.css"> 
    </head> 
    <body> 

    <style> 

    h1 
    { 
    font-family: "MV Boli", Times, Serif; 

    font-style: bold; 
    text-align: center; 
    font-size: 40px; 

    } 

    h2 
    { 

    font-family: "MV Boli", Times, Serif; 
    font-style: bold; 
    text-align: center; 
    font-size: 26px; 
    } 

    #text-container 
    { 
     width: 1045px; 
     height: 690px; */ 
     zoom: 1; 
     margin: 0; 
     display: inline-block 


    } 

    #text-container:after 
    { 
    clear: both; 
     content: "."; 
     display: block; 
     height: 0; 
     visibility:hidden; 

    } 

    #text-container > p 
    { 
    font-family: "Myriad Web Pro", Times, Serif; 
    font-size: 18px; 
    } 



    </style> 

    <div id="content"> 
    <div id="logo"> 
    <img src="./logo.png"></img> 
    </div> 
    <div id="container"> 
    <nav id="hor"> 
    <div><a href="home.html"> Home </a> </div> 
    <div><a href="mountains.html"> The Mountains </a></div> 
    <div><a href="resorts.html"> The Resorts </a></div> 
    <div><a href="snowReports.html"> Snow Reports </a></div> 
    <div><a href="eventsAndActivities.html"> Events &amp Activities </a></div> 
    <div><a href="planTrip.html"> Plan A Trip </a></div> 
    </nav> 
    <div id="middle"> 
    <nav id="vert"> 
    <a href="home.html"> Home </a> <br/> 
    <a href="mountains.html"> The Mountains </a><br/> 
    <a href="resorts.html"> The Resorts </a><br/> 
    <a href="snowReports.html"> Snow Reports </a><br/> 
    <a href="eventsAndActivities.html"> Events &amp Activities </a><br/> 
    <a href="planTrip.html"> Plan A Trip </a> 
    </nav> 

    <div id="text-container"> 
    <h1> The Resorts </h1> 
     <h2> The West Resort </h2> 
     <p> 
    The West Resort has everything from wide-open beginner areas to challenging terrain parks to gladed tree skiing hideaways. It has a young, energetic feel, but there's more to it than just jumps and jibs. West is 

    home to the Children's Sports Center, the Bullwheel Bar and Grill and the Foggy Goggle where fashion shows, movie premieres and live performances are held on a regular basis. 
     </p> 

    <h2> The East Resort </h2> 
    <p> 
    The East Resort boasts the longest trails in the region serviced by a single high-speed quad. Its long, groomed, cruising trails make it perfect for carving, but it is also home to the Olympic Bowl, the longest, 

    steepest bump run in the region. After a quick ascent on the Diamond Peaks Express, you'll find an additional 20 acres of beginner terrain up top. With 1,600 vertical feet of uninterrupted corduroy, the East 

    Resort offers traditional skiers and snowboarders a true alpine experience without having to journey far from home. 

     </p> 

    <h2> The North Resort </h2> 
     <p> 
    The North Resort is the perfect family-friendly ski resort with 70 acres of gently rolling terrain and historic, log cabins that are terrific for exploring. It is big enough to offer a true winter experience but small 

    enough to maintain its historical warmth and charm. Spend the afternoon shushing down the slopes or warm up by the fireplace with a cup of hot chocolate at the North Lodge. It is one of the region’s oldest 

    base lodges with ties that go back to the Big Pines ski clubs of the 1940s. 

     </p> 
     </div> 
    </div> 
    </div> 

    <div id="footercontainer"> 
    <footer> 
    &copy; 2016 

    </footer> 
    </div> 
    </div> 

    </body> 
    </html> 



==main.css== 

#logo 
{ 

border: 1px dashed purple; 
width: 1050; 
height: 75; 

} 

#logo > img 
{ 
width: 1050; 
height: 75; 

} 


#content 
{ 

border-left: 3px solid #283379; 
    border-right: 3px solid #283379; 
    text-align: left; 
    margin: 0 auto; 
    width: 960px; 
    background-color: #ffffff; 
    background-repeat: repeat-y; 
    height: 500; 



} 


nav 
{ 


     border: 10px solid transparent; 
padding: 15px; 
    border-image-source: url(./blue-diamond.gif); 
    border-image-repeat:repeat; 
    border-image-slice: 30; 

background-color: 2211ff; 
font-family: "Impact", Times, serif; 
font-size: 170%; 

} 

nav#vert 
{ 
width: 220;; 
height: 540; 
margin: 0; 

} 

body { 
    color: #000000; 
    margin: 0; 
    padding: 0; 
    font-family: Helvetica, Arial, sans-serif; 
    font-size: 16px; 
    background-color: #422520; 
    background-image: url(./image8.jpg); 
    background-repeat:no-repeat; 

    background-size:cover; 
    text-align: center; 
    background-attachment: fixed; 
    background-position: center; 
} 

#footerContainer 
{ 

border-left: 3px solid #283379; 
    border-right: 3px solid #283379; 
    text-align: left; 
    margin: 0 auto; 
    width: 980px; 
    background-color: #ffffff; 
    background-repeat: repeat-y; 

} 

footer 
{ 


    border: 10px solid transparent; 
padding: 15px; 


    text-align: left; 
    margin: 0 auto; 
    width: 1000px; 

    background-repeat: repeat-y; 

    border-image-source: url(./blue-diamond.gif); 
    border-image-repeat:repeat; 
    border-image-slice: 30; 

background-color: 2211ff; 
font-family: "Impact", Times, serif; 
font-size: 170%; 

} 

#container 
{ 
    border-left: 3px solid #283379; 
    border-right: 3px solid #283379; 
    text-align: left; 
    margin: 0 auto; 
    width: 1045px; 
    background-color: #ffffff; 
    background-repeat: repeat-y; 
    height: 690px; 

} 


nav > a 
{ 

color: #ccccff; 

} 

nav#hor > div 
{ 

border: 1px solid white; 
float: left; 
padding: 10px; 
} 

nav#hor 
{ 
width: 1000px; 
height: 50px; 
margin: 0; 

} 



nav#hor > div > a 
{ 

color: #ccccff; 
} 



nav#hor>div:hover 
{ 

background-color: #01ff02; 

} 
+0

フレックスボックスを使用する必要があります。 – SLaks

+0

それが何であるか分かりません。 – MongooseLover

+0

liとulを使用して終了することがあります。それは私が望むことをし、brタグの必要性を排除するかもしれません。 – MongooseLover

答えて

0

あなたは私が&アンプを固定

  • それらを明らかにするために、緑と赤の2つのブロックを色...

    https://jsfiddle.net/og9wpLmw/

    • を行きます。置くことによって ;最後に
    • 私はそれを作って固定しました
    • display:table-cell;
    • すべてのCSSをCSSファイルに入れます
    • 測定にpxを含めることで、nav#vertの幅を固定しました。ここで

    は違いCSSです:

    #text-container { 
        width: 1045px; 
        height: 690px; 
        */ zoom: 1; 
        margin: 0; 
        display: table-cell; 
        background-color:red; 
    } 
    nav#vert { 
        background-color:green; 
        width: 220px; 
        height: 540px; 
        margin: 0px; 
        display:table-cell; 
        } 
    
    +0

    これは、知識の明らかなギャップのいくつかをカバーしていません。 OPがテキストコンテナの幅を変更したいとし、それをより広くしたいとします。今、彼はなぜ彼らがもうお互いの隣にいなくなったのか分かりません... –

    0

    "vert"や "text-container"の幅が大きすぎる可能性があります。ここで

    0

    あなたは固定幅のナビゲーションを持っている - それが終わるので、幅が220pxに設定されているが、その後、あなたはパディング/マージンなどを持っています270px wide(nb。慣れていない場合は、最新のWebブラウザで要素を右クリックして、要素を簡単に測定してCSSのプロパティをチェックできる「inspect」を選択します)。

    他のテキストコンテナを右側に合わせるには、ナビの幅を考慮して幅を狭くする必要があります。これはあなたのテキストコンテナにそのCSSを追加(および他の幅の宣言を削除)し、それがうまくいくcalc

    width: calc(100% - 270px); 
    

    を使用することによって容易に達成することができます。これは、ベストプラクティスではありませんが、あなたはあなたを与える!importantを追加することにより、優先を取るためにこの宣言を強制することができます

    #text-container { 
        width: calc(100% - 270px) !important; 
    } 
    

    あなたはちょうどそれを中に追加したり、既存のCSSを修正する必要があり、あなたが行ってもいいです。

    +0

    PS。このようなレイアウトを作成するときは、最初にブロックとレイアウトフレームワークを作成する方が簡単です。必要なレイアウトを取得して、ナビゲーションバーやその他のビットとピースを導入してください。一旦あなたが望むレイアウトを手に入れたら、diffブラウザでテストして、他のコードを使って問題を複雑にする前に、どのように振る舞うか確認することができます。 –

    0

    これはうまくいきましたが、私が後で気づいた問題は、iframeを "text-container"の最初の要素として持っていて、iframeの前に何かがないと、nav barが壊れています再び。

    使用できる別のディスプレイがありますか?

    関連する問題