css html全宽无法正常工作 [英] css html full width not functioning properly

查看:104
本文介绍了css html全宽无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CSS:

#nav {
    width: 100%;
    float: left;
    }

#nav ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}

#nav li {
    float: left;
}

#nav li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

#nav a:hover:not(.active) {
    background-color: #111;
}

#nav.active {
background-color:#4CAF50;
}

HTML:

<body>

<div id="nav">
<ul>
  <li><a class="active" href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
</div></body>

我似乎有空间在顶部,我不能得到全宽?哪里不对?
无论我做什么,我似乎无法获得完整的宽度和顶部的间距删除。为什么宽度:100%不正常工作?

I seem to have space on top and I can't get the full width? what is wrong? No matter what I do I cannot seem to get the full width and the spacing on top removed. Why doesn't the width:100% work properly here?

推荐答案

尝试向body标记添加样式。

Try adding a style to the body tag.

body{
margin:0px;
padding:0px;
}

在Firefox中为我做了一个伎俩。

That did the trick for me in Firefox.

这篇关于css html全宽无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆