由于标题,无法一直向下滚动

时间:2016-05-11 20:07:03

标签: html css

我只希望我的内容(没有导航栏和标题)可滚动而不是整个页面。 我一直试着玩几个小时的位置,溢出等等。 我认为它与标题有关... 我很沮丧 - 有人可以帮忙吗? 提前致谢! 网站:https://jsfiddle.net/ronz2/0zxc13yv/3/

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,800,300);
*
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html
{
    height: 100%;
}

body
{
    font-family: 'Open Sans';
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

a
{
    text-decoration: none;
}

div#header
{
    width: 100%;
    height: 62px;
    background-color: #2980b9;
    margin: 0;
}

div#mssg
{
    display: inline-block;
    margin: 7px;
    padding: 2px;
    text-align: center;
    border-width: 5px;
    border-color: #67C8FF;
    border-style: solid;
    -webkit-transition: 0.1s;
    -moz-transition: 0.1s;
    transition: 0.1s;
}
div#mssg p
{
    font-size: 1.5em;
    color: White;
}

div#mssg:hover
{
    margin-top: 5px;
    padding-top: 4px;
    padding-bottom: 4px;
    border-style: solid dashed solid dashed;
}

.logo
{
    float: left;
    margin-top: 4px;
    margin-left: 15px;
}

.logo img
{
    width: 140px;
}

div#container
{
    margin-top: 62px;
    width: 100%;
    margin: 0;
    height: 100%;
}

.sidebar
{
    width: 250px;
    height: 100%;
    min-height: 100%;
    background-color: #171717;
    float: left;
}

.topbar
{
    width: 100%;
    background-color: #171717;
    text-align: center;
}

ul#topnav li
{
    display: inline-block;
    list-style: none;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    transition: 0.2s;
}

ul#topnav img
{
    width: 10px;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    transition: 0.2s;
}

ul#topnav li a
{
    display: inline-block;
    color: #ccc;
    font-size: 1em;
    padding-left: 5px;
    padding-right: 5px;
    margin-right: 0px;
    border-left: 1px solid #67C8FF;
    border-right: 1px solid #67C8FF;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    transition: 0.2s;
}

ul#topnav li a:hover
{
    background-color: Gray;
    color: #fff;
}

ul#topnav li a:hover img
{
    -webkit-transform: rotate(90deg);
    -moz-transform: rotate(90deg);
    transform: rotate(90deg);
}

ul#topnav ul
{
    display: none;
}

ul#topnav li:hover > ul
{
    display: block;
    background-color: #171717;
    position: absolute;
}

ul#topnav ul li
{
    display: block;
    margin-left: 0px;
}

ul#topnav ul li a
{
    display: block;
    width: 130px;
    border-bottom: 1px solid #67C8FF;
    border-top: 1px solid #67C8FF;
}

ul#nav li
{
    list-style: none;
    border-bottom: 1px solid #67C8FF;
    border-top: 1px solid #67C8FF;
}

ul#nav li a
{
    color: #ccc;
    display: block;
    padding: 10px;
    font-size: 1em;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    transition: 0.2s;
}

ul#nav li a:hover
{
    background-color: #030303;
    color: #fff;
    padding-left: 30px;
}

div#content
{
    width: auto;
    height: 100%;
    background-image: url("../Images/spaceBG.jpg");
    background-size: cover;
    background-repeat: no-repeat;
    padding: 15px;
    overflow-y: scroll;
}

div#content h1
{
    color: White;
    text-shadow: 4px 0 9px rgba(86,170,255,0.9) , 0 0 30px rgba(14,134,209,1) , 0 0 30px rgba(14,134,209,1);
}

div#content p
{
    color: White;
    font-size: 1em;
    text-shadow: 2px 1px Black;
}

div#box
{
    margin-top: 15px;
}

div#box .box-top
{
    color: #fff;
    text-shadow: 0px 1px #000;
    background-color: #2980b9;
    padding: 5px;
    padding-left: 15px;
    font-weight: 300;
    font-size: 1.5em;
}

div#box .box-panel
{
    padding: 15px;
    background-color: rgba(0, 20, 26, 0.89);
    color: White;
    font-size: 1.5em;
}

div#box .box-panel img
{
    vertical-align: middle;
    width: 450px;
}

.link
{
    color: #67C8FF;
    transition: 0.2s;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
}

.link:hover
{
    color: #67C8FF;
    text-shadow: 0px 0px 5px White;
}

div#box .box-panel .icon
{
    width: 30px;
}

.form
{
    margin-top: 10px;
    margin-bottom: 10px;
}

.form fieldset legend
{
    background-color: #2980b9;
    padding: 0 5px 0 5px;
    margin: 5px;
}

.field
{
    padding-left: 15px;
    color: White;
    text-shadow: 2px 1px Black;
}

.input
{
    padding: 10px 20px;
    margin: 5px 0 5px 0;
    border: 1px solid #b7b7b7;
    border-radius: 3px;
    color: rgba(0,142,198,1);
    text-overflow: clip;
    background-color: White;
    -webkit-box-shadow: 0 0 5px 2px rgba(0,0,0,0.5) inset;
    box-shadow: 0 0 5px 2px rgba(0,0,0,0.5) inset;
    -webkit-transition: all 200ms;
    -moz-transition: all 200m;
    transition: all 200ms;
}

.input:focus
{
    box-shadow: 0 0 5px 2px #2980b9 inset;
}

.options
{
    color: White;
    width: 150px;
    padding: 5px;
    font-size: 16px;
    line-height: 1;
    border-radius: 3px;
    background: url(../Images/arrowDown.png) no-repeat right rgba(0,142,198,0.7);
    -webkit-appearance: none;
}

.button
{
    cursor: pointer;
    padding: 10px 20px;
    border: 1px solid #018dc4;
    -webkit-border-radius: 3px;
    border-radius: 3px;
    color: rgba(255,255,255,1);
    text-overflow: clip;
    background: #0199d9;
    text-shadow: 0 0 7px rgba(0,0,0,1);
    -webkit-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
    -moz-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
    transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
}

.button:hover
{
    -webkit-box-shadow: 0 0 4px 2px rgba(126,193,234,1);
    box-shadow: 0 0 4px 2px rgba(126,193,234,1);
    -webkit-transition: all 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -moz-transition: all 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition: all 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.button:active
{
    -webkit-box-shadow: 0 0 4px 1px rgba(0,0,0,0.5) inset;
    box-shadow: 0 0 4px 1px rgba(0,0,0,0.5) inset;
    -webkit-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
    -moz-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
    transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
}

table
{
    border-collapse: collapse;
}
table#imgs
{
    padding-left: 95px;
}

table#imgs tr td
{
    padding: 15px;
}

.userTable
{
    font-size: 20px;
}

.userTable th , .userTable td
{
    padding: 0px 2px 0px 2px;
    border-bottom: 1px solid #67C8FF;
    text-align: left;
    border-left: 1px solid #67C8FF;
}

th.userTable 
{
    text-align: center;
}

.userNum
{
    text-align: center;
    margin-top: 10px;
}

.visit
{
    color: White;
    margin: 15px;
}
<head runat="server">
    <title>UniSci</title>
</head>
<body>
    <div id="container">
    <div id="header">
        <div class="logo">
            <a href="Default.aspx">
                <img src="Images/logo.png" alt="logo" /></a>
        </div>
    </div>
        <div class="topbar">
            <ul id="topnav">
                <li><a href="darkEn.aspx">Dark Energy
                    </a>
                    <ul>
                        <li><a href="darkEn-type.aspx">Types</a></li>
                    </ul>
                </li>
                <li><a href="darkMat.aspx">Dark Matter
                    </a>
                    <ul>
                        <li><a href="darkMat-type.aspx">Types</a></li>
                    </ul>
                </li>
                <li><a href="galaxy.aspx">Galaxies
                    </a>
                    <ul>
                        <li><a href="galaxy-create.aspx">Creation</a></li>
                        <li><a href="galaxy-type.aspx">Types</a></li>
                    </ul>
                </li>
                <li><a href="gasGiant.aspx">Gas Giants
                    </a>
                    <ul>
                        <li><a href="gasGiant-type.aspx">Types</a></li>
                    </ul>
                </li>
                <li><a href="universe.aspx">The Universe
                    </a>
                    <ul>
                        <li><a href="universe-create.aspx">Creation</a></li>
                        <li><a href="universe-dest.aspx">Destruction</a></li>
                    </ul>
                </li>
                <li><a href="spacetime.aspx">Spacetime
                    </a>
                    <ul>
                        <li><a href="spacetime-relative.aspx">Relativity</a></li>
                    </ul>
                </li>
                <li><a href="supernova.aspx">Supernova
                    </a>
                    <ul>
                        <li><a href="supernova-earth.aspx">Effect On Earth</a></li>
                    </ul>
                </li>
                <li><a href="star.aspx">Stars
                    </a>
                    <ul>
                        <li><a href="star-life.aspx">Life Course</a></li>
                    </ul>
                </li>
                <li><a href="starSys.aspx">Star Systems
                    </a>
                    <ul>
                        <li><a href="starSys-multi.aspx">Multiple star</a></li>
                        <li><a href="starSys-type.aspx">Types</a></li>
                    </ul>
                </li>
                <li><a href="universe-dest-info.aspx">Universe Death
                    </a>
                    <ul>
                        <li><a href="big-bounce.aspx">Big Bounce</a></li>
                        <li><a href="big-crunch.aspx">Big Crunch</a></li>
                        <li><a href="big-freeze.aspx">Big Freeze</a></li>
                        <li><a href="big-rip.aspx">Big Rip</a></li>
                    </ul>
                </li>
                <li><a href="gravity.aspx">Gravity
                    </a>
                    <ul>
                        <li><a href="gravity-waves.aspx">Waves</a></li>
                        <li><a href="gravity-relative.aspx">Relativity</a></li>
                    </ul>
                </li>
                <li><a href="big-bang.aspx">Big Bang
                   </a>
                    <ul>
                        <li><a href="big-bang-proof.aspx">Evidence</a></li>
                        <li><a href="big-bang-misc.aspx">Misconceptions</a></li>
                    </ul>
                </li>
                <li><a href="black-hole.aspx">Black Holes
                    </a>
                    <ul>
                        <li><a href="black-hole-create.aspx">Creation</a></li>
                        <li><a href="black-hole-dest.aspx">Destruction</a></li>
                    </ul>
                </li>
                <li><a href="wormhole.aspx">Wormholes
                    </a>
                    <ul>
                        <li><a href="wormhole-create.aspx">Creation</a></li>
                        <li><a href="wormhole-shape.aspx">Shape</a></li>
                    </ul>
                </li>
                <li><a href="extra.aspx">Extras
                    </a>
                    <ul>
                        <li><a href="extra-comet.aspx">Comets</a></li>
                        <li><a href="extra-asteroid.aspx">Asteroids</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <div class="sidebar">
            <ul id="nav">
                <li><a href="Default.aspx">Main Page</a></li>
                <li><a href="login.aspx">Login</a></li>
                <li><a href="regist.aspx">Register</a></li>
            </ul>
        </div>
        <div id="content"> <h1>
            Galaxy
            </h1>
            <div id="box">
                <div class="box-top">
                What types of galaxies are there?
                </div>
                <div class="box-panel">
                Ellipticals:<br />
                The Hubble classification system rates elliptical galaxies on <br />
                the basis of their ellipticity, ranging from E0, being nearly <br />
                spherical, up to E7, which is highly elongated. These galaxies <br />
                have an ellipsoidal profile, giving them an elliptical appearance <br />
                regardless of the viewing angle. Their appearance shows little structure <br />
                and they typically have relatively little interstellar matter. <br />
                Consequently, these galaxies also have a low portion of open <br />
                clusters and a reduced rate of new star formation. Instead they <br />
                are dominated by generally older, more evolved stars that are orbiting <br />
                the common center of gravity in random directions. The stars <br />
                contain low abundances of heavy elements because star formation ceases <br />
                after the initial burst. In this sense they have some similarity to the <br />
                much smaller globular clusters.<br />
                <br />
                Shell galaxy:<br />
                A shell galaxy is a type of elliptical galaxy where the stars in <br />
                the galaxy's halo are arranged in concentric shells. About one-tenth <br />
                of elliptical galaxies have a shell-like structure, which has never<br />
                been observed in spiral galaxies. The shell-like structures are <br />
                thought to develop when a larger galaxy absorbs a smaller companion<br />
                galaxy. As the two galaxy centers approach, the centers start to oscillate <br />
                around a center point, the oscillation creates gravitational <br />
                ripples forming the shells of stars, similar to ripples spreading on water. <br />
                For example, galaxy NGC 3923 has over twenty shells.<br />
                <br />
                Spirals:<br />
                Spiral galaxies resemble spiraling pinwheels. Though the stars and other<br />
                visible material contained in such a galaxy lie mostly on a plane, the <br />
                majority of mass in spiral galaxies exists in a roughly spherical halo of <br />
                dark matter that extends beyond the visible component, as demonstrated <br />
                by the universal rotation curve concept. Spiral galaxies consist of a rotating <br />
                disk of stars and interstellar medium, along with a central bulge of generally <br />
                older stars. Extending outward from the bulge are relatively bright arms. <br />
                It appears the reason that some spiral galaxies are fat and bulging while some <br />
                are flat discs is because of how fast they rotate.
            </div>

2 个答案:

答案 0 :(得分:1)

标题没问题,

正文设置为overflow:hidden,这就是为什么底部不显示

答案 1 :(得分:0)

更改容器的高度,类似于:

#container {
    margin-top: 62px;
    width: 100%;
    margin: 0;
    height: calc(100% - 131px);
}

问题是您减去的精确px值:根据视口的宽度,导航将分布在不同的行数上。修复#topnav的高度或使用#container的不同高度计算的媒体查询。

ADDED小提琴:https://jsfiddle.net/s3qeu8vu/