获取标题以与页面顶部对齐

获取标题以与页面顶部对齐

本文介绍了获取标题以与页面顶部对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始构建这个网站时遇到了这个奇怪的问题。我想让页眉与页面顶部完全齐平。但由于某种原因,有一个小的空间,大约20px高,不管我尝试什么都不会消失。我假设只有一些关于CSS和html的东西,我没有得到,所以你们能帮我一下吗?

I'm having this weird problem with this website I just started building. I want to get the header to align completely flush with the top of the page. But for some reason, there's a small space, about 20px high, that won't go away no matter what I try. I'm assuming there's just something about CSS and html that I'm not getting so can you guys help me out?

CSS

#header {
    background-color:#3429C9;
    /*-webkit-border-radius:15px;
    -moz-border-radius:15px;
    border-radius:15px;*/
    display:block;
    position:relative;
    z-index:2;
    margin-top:-20px;
    border-bottom:2px solid white;
    margin-bottom:20px;
    height:60px;
}

body {
    text-align:center;
    font-family: Georgia, Serif;
    background: #000000;
    margin:0;
    height:100px;
    display:block;
    border:2px solid red;
}


推荐答案

,IE)有一个默认的CSS,它给出了元素的默认样式。它也提供了一些默认的边距/填充,所以通常在开始网站设计时,应该使用来重置所有默认样式。

Every browser (firefox,chrome,IE) have a default CSS it comes with which give default styling to elements. It also gives some default margin/padding, so usually when starting a web site design you should use a css reset file to reset all default styling.

这样您就可以在所有浏览器中获得相同的基本行为。

That way you get the same basic behaviour for all browsers.

要快速解决yuor问题,只需将标题填充/页边距设置为0即可。

For a quick solution to yuor problem, just set the header padding/margin to 0.

这篇关于获取标题以与页面顶部对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 00:30