Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.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
添加DocType会破坏我的html的整个样式表_Html_Css - Fatal编程技术网

添加DocType会破坏我的html的整个样式表

添加DocType会破坏我的html的整个样式表,html,css,Html,Css,因此,当我添加DOCtype以通过HTML上的代码验证时,我插入的图像和div上的背景色消失了,但是作为标题的前4个div仍然保持其背景色和位置不变,但div的高度不是我指定的高度。我知道外部CSS正在工作,因为前4个div的背景色正在工作。但是,当我只使用普通HTML而不指定DocType时,它工作得很好 请帮忙,谢谢你 注意:我的HTML上有外部JavaScript,我不知道它是否会影响它 例如: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0

因此,当我添加DOCtype以通过HTML上的代码验证时,我插入的图像和div上的背景色消失了,但是作为标题的前4个div仍然保持其背景色和位置不变,但div的高度不是我指定的高度。我知道外部CSS正在工作,因为前4个div的背景色正在工作。但是,当我只使用普通HTML而不指定DocType时,它工作得很好

请帮忙,谢谢你

注意:我的HTML上有外部JavaScript,我不知道它是否会影响它

例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<body> etc...

您没有在layout.css中添加px/%

现在您可以添加DOCTYPE了,它可以工作了

#header a:hover
{
text-align: center;
text-decoration: none;
font-size: 50;
color: black;
font-family: tunga;

}

#Welcome
{
margin-top: 0;
text-align: center;
font-size: 40;
height: 70;
width: auto;
background-color: red;
font-family: Browallia New;

}

#NavContainer
{
margin-top: 0;
margin-left: 250;
height: 60;
width: 700;
background-color: gray;
}

#NavContainer a
{

margin-top: 20;
font-family: Browallia New;
font-size: 18;
text-decoration: none;
padding: 15px;

}
应该是

#header a:hover
    {
    text-align: center;
    text-decoration: none;
    font-size: 50px;
    color: black;
    font-family: tunga;

    }

    #Welcome
    {
    margin-top: 0;
    text-align: center;
    font-size: 40px;
    height: 70px;
    width: auto;
    background-color: red;
    font-family: Browallia New;

    }

    #NavContainer
    {
    margin-top: 0;
    margin-left: 250px;
    height: 60px;
    width: 700px;
    background-color: gray;
    }

    #NavContainer a
    {

    margin-top: 20px;
    font-family: Browallia New;
    font-size: 18px;
    text-decoration: none;
    padding: 15px;

    }

像这样更新您的文档类型(您的页面已被编码为依赖于浏览器错误,即在怪癖模式下运行。无需进一步信息,就可以这么说。没有任何更改,但我的整个代码在没有任何更改的情况下都能完美工作,但我仍然希望通过验证代码,所以我不能忽略它。即使我执行了
此操作,我似乎也无法放置整个代码,然后粘贴代码就不起作用了。)没什么意义等一下
我只是给了链接只是查看页面源代码它似乎运行正常,但当我验证它时,我得到了很多错误希望你能帮助我非常感谢!你好,谢谢,我重新验证了它,验证说我的代码没有错误,但是当你说问题只是在我的布局上。css我尝试替换了你编写的代码e在我的#标题a中:将鼠标悬停到#NavContainer a它确实做了一些更改,但几乎还是一样,图像仍然没有出现。您可以再次检查我的页面源代码。在您回复之前,我不会进行更改。谢谢。非常感谢。不,非常感谢我不知道添加px的问题或%因为当我脱机时,它只起作用别以为你帮了大忙。