javascript - 页面底部和内容之间的间距?

标签 javascript jquery html css

我页面上的主容器包含所有内容,并且应该占据页面的整个长度。但由于某种原因,底部有一个小缝隙,显示了它背后的背景。有什么想法吗? 非常感谢。

这是我的代码:

HTML:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>GS4 Concept Home Page</title>
<link type="text/css" href="unicss.css" rel="stylesheet"/>
<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<script src="Script/jquery.js"></script>
<script src="Script/main.js"></script>
</head>

<body>
    <div id="header"><h1 class="headover">You Are Home.</h1>
    <div class="nav">
        <ul class="navigation">
                <li><a href="#">Home</a></li>
                <li><a href="#">Galaxy S4</a>
                <ul>
                    <li><a href="#">Verizon</a></li>
                    <li><a href="#">ATT</a></li>
                    <li><a href="#">Sprint</a></li>
                    <li><a href="#">T-Mobile</a></li>
                    <li><a href="#">International</a></li>
                </ul>
                </li>

        </ul>
    </div>
</div>
    <div id="container">//breaks for testings sake
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </div><center><img src="Images/Galaxy_Family.jpg" width="70%" /></center>

</body>
</html>

CSS:

 body {
    background-image:url(Images/backgroundmain.jpg);
    min-width:100%;
    font-family: Arial, Helvetica, sans-serif;
    font-size:15px;
    margin:0;
}

.headover{
    color:#333;
    float:right;
}
.headover:hover{
    color:white;
}

#gfamily{
    margin:auto
}

#header{
    position:fixed;
    text-align:center;
    background-color:#666;
    margin:auto;
    width:100%;
    height:54px;
    display:block;
    min-width:1000px;
}

#container{
    background-color:#FFF;
    margin:auto;
    width:70%;
    min-height:100%;
}

.nav{
    margin-left:5px;
    text-align:center;
    background-color:#999;
}

.navigation {
    position:fixed;
    display:block;
    margin-top:15px;
    padding:0;
    list-style:none;
}

.navigation li {
    float:left;
    width:150px;
    position:relative;
}

.navigation li a {
    background:#262626;
    color:#fff;
    display:block;
    padding:8px 7px 8px 7px;
    text-decoration:none;
    border-top:1px solid #FFF;
    border-bottom:1px solid #FFF;
    text-align:center;
    text-transform:uppercase;
}
.navigation li a:hover {
    color:#666;
}

.navigation ul {
    position:absolute;
    left:0;
    display:none;
    margin:0 0 0 -1px;
    padding:0;
    list-style:none;
    border-bottom:1px solid #FFF;
}

.navigation ul li {
    width:150px;
    float:left;
    border-top:none;
}

.navigation ul a {
    display:block;
    height:15px;
    padding:8px 7px 13px 7px;
    color:#fff;
    text-decoration:none;
    border-top:none;
    border-bottom:1px solid #FFF;
}

.navigation ul a:hover {
    color:#666;
}

JavaScript(如果它重要..?):

// Executes the function when DOM will be loaded fully
$(document).ready(function () {
// hover property will help us set the events for mouse enter and mouse leave
    $('.navigation li').hover(
// When mouse enters the .navigation element
        function () {
//Fade in the navigation submenu
            $('ul', this).fadeIn(); // fadeIn will show the sub cat menu
        },
// When mouse leaves the .navigation element
        function () {
//Fade out the navigation submenu
            $('ul', this).fadeOut(); // fadeOut will hide the sub cat menu
        }
    );
});

Shows the space on the bottom of the page

最佳答案

如果您希望将图像保留在主容器之外,您可以将 img display 属性更改为 block 而不是默认的 inline 值。我还建议用 margin 属性设置为 auto 替换中心标签,因为中心标签是 not supported in HTML5 .

img{
  display:block;
  margin:auto;
}

关于javascript - 页面底部和内容之间的间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22750100/

相关文章:

javascript - 通过 http 发送音频文件

javascript - 多部分/表单数据上传 - Nodejs - expressjs

javascript - 如何使用 jQuery 动态添加外部脚本?

javascript - 文本区域自动完成 - 使用 JavaScript 将文本输入定位在文本区域的光标位置之上

html - 是否应完整定义 CSS 链接声明以保持跨浏览器的一致性

javascript - 在什么情况下 window.location.search 是未定义的?

jquery - TS-2304 错误 - 在 'Iterable' 文件中导入 "jquery"时在 TypeScript 中找不到名称 ".ts"

jquery - 更改 Bootstrap 事件选项卡颜色内联

jquery - 在 iPhone 上更改 div 的 bg 图像不起作用

javascript - 当使用 html 和 css 单击按钮图像时,如何使用按钮图像获取按钮图像源