Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.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 为什么我的标题和导航在我的英雄形象下面?_Css_Header_Navigation - Fatal编程技术网

Css 为什么我的标题和导航在我的英雄形象下面?

Css 为什么我的标题和导航在我的英雄形象下面?,css,header,navigation,Css,Header,Navigation,为什么我的标题和导航在我的英雄形象下面? 每当我增加图像上文本的大小时,导航和标题都会进一步下降。如果我去掉了文本的大小,它会回到我想要的地方。 这是我的html和css HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Amanda Farrington</title> <link rel="stylesheet"

为什么我的标题和导航在我的英雄形象下面? 每当我增加图像上文本的大小时,导航和标题都会进一步下降。如果我去掉了文本的大小,它会回到我想要的地方。 这是我的html和css

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Amanda Farrington</title>
<link rel="stylesheet" href="css/demo.css" />
<link href='http://fonts.googleapis.com/css?family=Roboto:400,300,500' rel='stylesheet' type='text/css'>
</head>

<body>


    <div id="header">
        <div id="leftHeader">
        <img src="assets/logo2.jpg" alt="Logo" style="width:65px;height:65px">
        <h1>Amanda Farrington</h1>
    </div>
        <div id="nav">

      <ul>
        <li><a href="index.html">About</a></li>
        <li><a href="tips.html">Work</a></li>
        <li><a href="mentally.html">Contact</a></li>
      </ul>

        </div>



    </div>



    <div id="hero">
        <div id="heroImage">
        <img src="assets/trees.jpg" alt="trees" style="width:100%;height:10%">
        </div>

        <div id="overlay">
        <h2>Amanda Farrington</h2>
        </div>
    </div>

</body>
</html>

这是因为
位置:绝对#hegomage
div的code>(如果我理解,你想要什么)

如果我希望图像是静态的,并且位于div“header”的正下方,我应该将其更改为什么?我还希望div“overlay”位于图像的顶部。添加到
#header{position:relative;}
#hero{position:relative}
,然后将
position:absolute
放在#herogramage,这很有帮助!但是如果你把背景变成红色的div“header”,上面会有一个很大的空白。是什么原因造成的?也许试着玩一下
#hegomage{top:12%;}
body {
  margin: 0px;
  padding: 0px;
  height: 100%;
  background: white;

}

#header {
  color: #D7DADB;
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
  font-size : 15px;
  text-align: left;
  width: 97%;
  margin:0;
  padding-left: 3em;
  float: left;
  background: white;
  height: 10%;

}

#leftHeader
{
}

#header img
{
    float: left;
    padding-left: 3em;
}

h1{
width: 9em;
float: left;
padding-left: 0.5em;
color: #45CCCC;
padding-bottom: 1px;
}



#nav {
  width: 40%;
  margin:0;
  padding:0;
  text-align: right;
  color: red;
  font-size:20px;
  float: right;
  padding-right: 2em;


}

#nav ul {
  padding: 1px;
}

#nav li {
  display: inline;
  padding: 38px;
}

#nav li a {
  color: #2C3E50;
  text-decoration: none;
}

#nav li a:hover {
  color: #45CCCC;
}

#hero{
    width: 100%;
    height: 30em;
}

#heroImage
{
    top: 12%;
    width: 100%;
    z-index: 1;
    position: absolute;
}

#overlay{
    width: 30em;
    top: 90%;
    margin-left: 30%;
    z-index: 2;
    position: relative;
}

h2{
    width: 9em;
    position: relative;
    font-family: 'Roboto', sans-serif;
    font-weight: 300;
    font-size: 60px;
    float: center;
    color: white;
    opacity: 1.0;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
}