Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css div之间的Html定位差距_Css_Html_Layout - Fatal编程技术网

Css div之间的Html定位差距

Css div之间的Html定位差距,css,html,layout,Css,Html,Layout,我有一个html布局问题,下面是代码,当你打开页面时,菜单栏和灰色框之间有一个空间,我想去掉这个空间,所以它们之间只有一个很小的间隙,如果有人能帮忙,我将不胜感激 HTML: <html> <head> <meta content="en-gb" http-equiv="Content-Language"> <title>Cleveland Potash Intranet</title> <link href="style.cs

我有一个html布局问题,下面是代码,当你打开页面时,菜单栏和灰色框之间有一个空间,我想去掉这个空间,所以它们之间只有一个很小的间隙,如果有人能帮忙,我将不胜感激

HTML:

<html>

<head>
<meta content="en-gb" http-equiv="Content-Language">
<title>Cleveland Potash Intranet</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
.auto-style1 {
    text-align: center;
    margin-left: 1px;
    margin-top: 11px;
    font-family: Georgia;
    margin-right: 0px;
}s
#bannerdiv {
    text-align: center;
}
.auto-style4 {
    margin-left: 0px;
    text-align: left;
}
.auto-style5 {
    margin-top: 0px;
}
</style>
</head>

<body>




<div id="bannerdiv" align="left" title="Banner">
    </div>
<div id="container">
    <h3 class="auto-style4" id="container">&nbsp;</h3>
</div>
<div id="menubar" style="width: 15%; height: 100px;" title="menu">
    <ul>
        <li><a href="#home" style="height: 20px" class="auto-style5">Home</a></li>
        <li><a href="#news">News</a></li>
        <li><a href="#contact">Contact</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#home" style="height: 20px">Home</a></li>
        <li><a href="#news">News</a></li>
        <li><a href="#contact">Contact</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#home" style="height: 20px; width: 121px;">Home</a></li>
        <li><a href="#news">News</a></li>
        <li><a href="#contact">Contact</a></li>
        <li><a href="#about">About</a></li>


    </ul>
</div>
<div id="mainpage" class="auto-style1" style="height: 96px; width:   84%; float:right;height:84%; color: #000000; font-size: 11pt;"> 
</div>




</body>

</html>

id=“menubar”
上的内联样式宽度从15%更改为10%,并添加一个设置为130px的
minwidth
元素。然后移除内联
float:rightid=“mainpage”
中选择code>,并将其
宽度更改为89%。这应该会提高间距,但值得一提的是,内联样式并不是一种很好的html样式设计方法。您应该在链接到html文件的css文档中定义所有样式

Pff、CSS在3个位置。。。。主要原因是
15+84=99%
width!也许您只需要在
.CSS
文件中使用并放置CSS。不内联,不在
标记中您有相同的ID。不是很好的HTML编码风格。ID应该是唯一的,即每个实例一个,避免内联CSS(style=“/*不要使用我*/”),这里有一个JSFIDLE供人们使用:
#container {
    margin: 0px;
    background-color: #008852;
    font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
    color: #FFFFFF;
    text-align: left;
    max-width: 10%;
}

#main
{
height:100%;
weight:100&
}

html, body {
overflow: hidden;
height:100%;}

#menubar

ul
{
list-style-type:none;
margin:0;
padding:0;
}
a:link,a:visited
{
    border-top-width: 1px;
    display: block;
    font-weight: bold;
    color: #000000;
    background-color: #EFF1EB;
    width: 120px;
    text-align: center;
    padding: 4px;
    text-decoration: none;
    text-transform: uppercase;
    border-style: solid;
    border-color: #638529;
    font-family: Arial, Helvetica, sans-serif;
    border: 1px;
}
a:hover,a:active
{
background-color:#7A991A;
}
#mainpage {
    width: 50%;
    float: left;
    background-color: #EDEFEE;
    height: auto;
    border-radius: 20px ;
}
#menubar {
    border-width: 1px;
    border-style: none;
    font-size: xx-small;
    width: 50%;
    margin-top:11px;
    float: left;
}
#bannerdiv 
{

    margin-bottom:20px;
}

.newStyle1 {
    text-align: left;
}