当网站内容溢出时,Cant向上滚动?

时间:2015-04-24 23:01:53

标签: javascript html css scrollbar overflow

除了代码之外,没有其他说法。当分辨率足够小时,我不能向上滚动,东西溢出,我无法查看那些东西。虽然我可以向下滚动

我使用JavaScript分配,因为它是一款游戏。它的广泛发布方式,但如果你真的想要它告诉我

HTML

<html>
<head>

</head>
<body>
    <canvas id="canvas">You're browser does not support the canvas tag. Go and get a real browser, nub</canvas>
    <div id="redSelector">
        <div class="genericButton" id="zombieRed">Zombie</div>
        <div class="genericButton" id="skeletonRed">Skeleton</div>
         <div class="genericButton" id="creeperRed">Creeper</div>
        <div class="genericButton" id="spideBlue">Spider</div>
    </div>
    <div id="blueSelector">
        <div class="genericButton" id="zombieBlue">Zombie</div>
        <div class="genericButton" id="skeletonBlue">Skeleton</div>
         <div class="genericButton" id="creeperBlue">Creeper</div>
        <div class="genericButton" id="spiderBlue">Spider</div>
    </div>
    <div id="options">

        <div class="lineContainer">
            <div class="heading" id="Options-heading">Insert Title Here</div>
        </div>
        <div class="lineContainer">
            <div class="text" id="Options-info">Welcome to Insert Title Here. This game is a strategic game with an scaled up<br>
                                                rock paper scissors concept. To beat you're opponent, You must select certain<br> 
                                                mobs that do good against you're opponents mobs. You can also make combinations<br> 
                                                of mobs to destroy you're opponents base but you must take into consideration <br>
                                                the prices. better mobs require more money and take up more population.</div>
        </div>
        <div class="lineContainer">
            <div id="Restart" class="options-button">Restart</div>
            <div id="Exit" class="options-button">Exit</div>
            <div id="Play" class="options-button">Play</div>
        </div>
        <div class="lineContainer">        
            <div id="Credits" class="options-button">Credits</div>
            <div id="Support" class="options-button">Contact</div>
            <div id="Controls" class="options-button">Controls</div>
        </div>
        <div class="lineContainer">
            <div id="CreditsInfo" class="options-tab">Made entirely by _____ ____</div>
            <div id="SupportInfo" class = "options-tab">Please tell me what you think and how I could improve. (Link)</div>
            <div id="ControlsInfo" class="options-tab">A-D to move player 1 scrollbar. J-L to move player 2 scrollbar. Hover over mob to see stats. Press O to pause.</div>
        </div>
    </div>
    <link rel="stylesheet" href="normalize.css">
    <link rel="stylesheet" href="main.css">
    <script src="jquery.js"></script>
    <script src="rectangle.js"></script>
    <script src="main.js"></script>
</body>

CSS

html {
    overflow: -moz-scrollbars-horizontal;
    overflow-x: scroll;
    -webkit-user-select: none;
    -moz-user-select: none;
}

html, body {
  width:  100%;
  height: 100%;
  margin: 0px;
  background-color: rgb(50, 50, 50);  
}
#Options-info{
    display: inline-block;
    background-color: rgb(255, 153, 0);
    border: 2px solid black;
    padding: 5px 5px;
    margin: 5px;

}

#redSelector{
    position: absolute;
    top: 0px;
    left: 0px;
    width: 0px auto;
    height: 100px;
    background-color: red;
    margin: 0px auto;
    border: 2px solid black
}
#blueSelector{
    position: absolute;
    top: 0px ;
    left: 0px;
    width: 0px auto;
    height: 100px;
    background-color: blue;
    margin: 0px auto;
    border: 2px solid black;
}
.genericButton{ 
    position: relative;
    display: inline-block;
    background-color: green;
    width: 50;
    height: 75;
    margin: 10;
    border: 2px solid black
}
#canvas{
    border: 10px solid black;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    background-color: rgb(100, 100, 100);
}
#options{
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 80%;
    height: 650px;
    border: 10px solid black;
    background-color: rgb(200, 200, 200);
    margin: auto;
    text-align: center;
}

.options-button {
    display: inline-block;
    padding: 25px 25px;
    font-size: 30px;
    background-color: rgb(255, 153, 0);
    margin: 5px;
    width: 100px;
    cursor: pointer;
    border: 2px solid black;

}
.options-tab{
    display: none;
    padding: 15px 15px;
    font-size: 20px;
    width: 200px;
    border: 2px solid black;
    margin: 5px;
    background-color: rgb(0, 153, 255)
}
.options-button:hover {
    background-color: rgb(155, 103, 0)
}
.options-button:active{
    position: relative;
    top: 1;
}

.heading{
    font-size: 75px;
    display: inline-block;
    padding: 25px 25px;
    background-color: rgb(255, 153, 0);
    margin: 5px;
    border: 2px solid black;
}
.lineContainer{

}

1 个答案:

答案 0 :(得分:0)

您已使用绝对定位元素。 修复ID为&#34;选项&#34;的主容器。并包含选项按钮。

变化:     #options {      位置:绝对;      顶部:0;      底部:0;      左:0;      右:0;      宽度:80%;      身高:650px;      边框:10px纯黑色;      background-color:rgb(200,200,200);      保证金:自动;      text-align:center;     }

于:     #options {      位置:相对;      宽度:80%;      身高:650px;      边框:10px纯黑色;      background-color:rgb(200,200,200);      保证金:0自动;      text-align:center;     }

我还建议您将#options的height属性更改为auto,以便扩展容器的大小。

您很可能需要更改其他元素的位置以停止重叠。