html - 在正常流程中缩小我的 div 之间的差距

标签 html css

我想弄清楚如何控制我的 div 之间的间隙。我已经设置了果冻布局并开始在我的导航栏上工作,当间隙变得一团糟时。试图回溯一切,只剩下默认流布局和间隙中的 div。这是 html 代码:

body { 
    background-image: url("images/ozadjeCrno.jpg");
    background-size: 100%;
    background-repeat: repeat-y;
    font-family:      Georgia, "Times New Roman", Times, serif;
    font-size:        small;
}

#container{
    width: 900px;
    height: 600px;
    margin-left: auto;
    margin-right: auto;
}

#header{
    width: 900px;
    height: 100px; 
    background-color: rgba(207, 207, 207, 0.94);
}

#navigation{
    width: 900px;
    height: 30px;
    background-color: rgba(207, 207, 207, 0.94);
}

#navigation ul li{
    display: inline;
}

#logoLeft{
    margin: 20px;
    width: 140px;
    height: 60px;
}

#logoRight{
    margin: 20px;
    width: 110px;
    height: 60px;
    float: right;
}

#sidebar{
    background-color: rgba(207, 207, 207, 0.94);
    width: 255px;
    height: 100px;
}

#main {
    background-color: rgba(207, 207, 207, 0.94);
    height: 100px;
}

#footer{
    background-color: rgba(207, 207, 207, 0.94);
}


.shadow {
    -moz-box-shadow: 5px 5px 5px rgba(0,0,0,0.5);
    -webkit-box-shadow: 5px 5px 5px rgba(0,0,0,0.5);
    box-shadow: 5px 5px 5px rgba(0,0,0,0.5);
}

.roundedCorners{
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}
<html>
    <head>
        <title>Solska Impro Liga</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" type="text/css" href="spletka.css">
    </head>
    <body>
        <div id="container">

            <div id="header" class="shadow roundedCorners">
                <img id="logoRight" src="images/logo1.png" alt="logo1">
                <img id="logoLeft" src="images/logo2.png" alt="logo1">
            </div>
            <div id="navigation" class="shadow roundedCorners">
                <ul id="navButtonsList">
                <li><a href="" title="domov">DOMOV</a></li>
                <li><a href="" title="domov">ŠILARJI</a></li>
                <li><a href="" title="domov">O ŠILI</a></li>
                <li><a href="" title="domov">ARHIV</a></li>
                <li><a href="" title="domov">ENG</a></li>
                </ul>               
            </div>
            <div id="sidebar" class="shadow roundedCorners">
                <h1>SIDEBAR</h1>
            </div>
            <div id="main" class="shadow roundedCorners">
                <h1>MAIN</h1>
            </div>
            <div id="footer" class="shadow roundedCorners">
                <h1>FOOTER</h1>
            </div>
        </div>
    </body>
</html>

我想张贴截图,但我不能,因为我需要 10 个声望点:/

谢谢你的时间, 最好的问候。

最佳答案

div 之间存在间隙的原因是标题标签。为您的父 div 使用 overflow: hidden 而不是标题边距不会开箱即用,并且为您的父 div 添加边距以便您可以控制它们之间的距离。

如果您不想使用 overflow: hidden,您可以将标题标签边距更改为填充。再一次,您可以用边距控制父 div 之间的距离。

关于html - 在正常流程中缩小我的 div 之间的差距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27281379/

相关文章:

javascript - 尝试使用变量更改背景颜色

css - Rails 3.1 - 有错误的字段

css - 定位带有溢出支持的 sticky polyfill

javascript - Bootstrap 3 : Mobile nav opens on desktop, 但不是在 iPhone 上?

css - 网址格式错误时如何显示背景图片

javascript - 突出显示当前菜单项不起作用,为什么?

javascript - 如何关联两个 DOM 元素?

javascript - 检测 CAPS LOCK 何时打开

css - 垂直对齐 Div 框中图像下的文本?

javascript - 十五益智游戏