如何修复我的导航和页脚?

时间:2017-09-20 18:40:47

标签: html css responsive-design

导航采用全屏宽度,页脚贴在左侧。两者都是错的,我希望导航的宽度为90%,并且两者都居中。我希望我能理解这个问题。

html代码:



@media only screen
	and (device-width: 3840px) 
	and (device-height: 2160px)
	and (orientation: landscape) {

		body {
          	width: 90%;
         	font-size: 300%;
     	}

		.mainHeader img.Margrit {
			height: auto;
			width: 12%;
			top: 20%;
		}

		.mainHeader img.Logo {
			height: auto;		
			width: 12%;
			top: 60%;
		}

		.mainHeader img.Couture {
			height: auto;
			left: 0%;
			top: -18%;
			width: 75%;
		}

		.mainHeader nav {
		  width: 90%;
          height: 100px;
      }
      
      	.mainHeader nav ul {
		padding-left: 0;
		}

	  	.mainHeader nav ul li {
		width: 25%;
		text-align: center;
		}

	  	.mainHeader nav a:link, .mainHeader nav a:visited {
		padding: 20px 367px;
		height: 59px;
	    display: inline-block;
		}
      
		.mainFooter {
			display: table;
			height: 100px;
			width: 90%;
			text-align: center;
		}

      	.mainFooter p {
		  display: table-cell;
	      vertical-align: middle;
          text-align: left;
		  padding-left: 1%;
      	}
}

<!DOCTYPE html>
<html lang="de">
    <head>
		<title>Couture Anni</title>
		<meta charset="utf-8">
		
        <link rel="stylesheet" type="text/css" href="resources/css/style.css">
        <link href="https://fonts.googleapis.com/css?family=Coming+Soon" rel="stylesheet">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
		<header class="mainHeader">
			<img class="Logo" src="resources/img/Content_variation_800_e.png" alt="Logo">
			<img class="Margrit" src="resources/img/IMG_5347_small.jpg" alt="Annamaria Hofstetter">
			<img class="Couture" src="resources/img/Content_variation_800_g.png" alt="Couture Anni">
			
			<nav>
				
				<ul>
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Portfolio</a></li>
                    <li><a href="#">Kontakt</a></li>
                </ul>
				
		    </nav>
		</header>
		
		
        
        <footer class="mainFooter">
            <p>Copyright &copy; <a href="#" title="couture-anni">couture-anni.ch</a></p>
        </footer>
        
    </body>


</html>
&#13;
&#13;
&#13;

我之所以选择此查询是因为它会重现此问题。至少我认为。

1 个答案:

答案 0 :(得分:0)

您应该将body元素保持在100%并从那里调整其他内容的大小。保证金:0自动;注意使你的元素居中。

body{
  width: 100%;
}
.mainHeader{
  width: 90%;
  margin: 0 auto;
}
.mainFooter{
  position: fixed;
  width: 100%;
  bottom: 3%;
}
.mainFooter .footerBody{
  width: 90%;
  margin:0 auto;
  height: 40px;
  clear: both;
  text-align: left;
  border-radius: 5px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  background-color: #9cb34f;
}
.mainFooter .footerBody p {
   display: table-cell;
   vertical-align: middle;
   text-align: left;
   padding-left: 1%;
   margin-top: 0;
 }

至于你的页脚,使用mainFooter类作为固定定位的包装,然后在其中添加一个90%大小的容器并设置display:block;

<footer class="mainFooter">
  <div class="footerBody">
    <p>Copyright © <a href="#" title="couture-anni">couture-anni.ch</a></p>
  </div>
</footer>

希望这有帮助!