【发布时间】:2017-07-07 09:57:37
【问题描述】:
您好,我为我的网站制作了一个网格,我遇到的问题是网格与页脚元素重叠我一直在尝试从设置网格容器到自动高度以查看它是否自动调整我无法给出它是一个设定的高度,因为网站是响应式的
<html>
<head>
<link href="/styles.css" rel="stylesheet" type="text/css">
<link href="/services-styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<div class="header">
<div class="nav">
<ul>
<li><a href="/index.html">Home</a></li>
<li><a href="/services.html">Services</a></li>
<li><a href="/aboutus.html">About us</a></li>
<li><a href="/contact.html">Contact</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="title logo">
<h1>Logo's</h1>
</div>
<div class="title">
<h1>"Just a Glimpse of what we can do for you and your business"</h1>
</div>
<div class="Grid1">
<div class="Gallery1">
<a href="Images/logo1.jpg">
<img src="/Images/logo1.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo2.png">
<img src="/Images/logo2.png"style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo3.jpg">
<img src="/Images/logo3.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo-grid3.jpg">
<img src="/Images/logo-grid3.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo-grid3.jpg">
<img src="/Images/logo-grid3.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo-grid3.jpg">
<img src="/Images/logo-grid3.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo-grid3.jpg">
<img src="/Images/logo-grid3.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo-grid3.jpg">
<img src="/Images/logo-grid3.jpg" style="width:100%; height:100%;">
</a>
</div>
<div class="Gallery1">
<a href="Images/logo-grid3.jpg">
<img src="/Images/logo-grid3.jpg" style="width:100%; height:100%;">
</a>
</div>
</div>
</div>
<footer>
<div class="Footer-Nav">
<ul>
<li><a href="/index.html">Home</a></li>
<li><a href="/services.html">Services</a></li>
<li><a href="/aboutus.html">About us</a></li>
<li><a href="/contact.html">Contact</a></li>
</ul>
</div>
</footer>
</div>
</body>
</html>
这是所有页面主要样式的代码
.Gallery1{
margin:5px;
float: left;
width:300px;
height:200px;
position:relative;
border: 1px solid #ccc;
}
.Grid1{
max-width:945px;
position: relative;
height:auto;
margin:0 auto;
margin-top: 25px;
}
div.logo{
margin-top: 15px;
text-align: center;
font-size: 40px;
font-family: Monospace;
padding: 5px;
}
div.Gallery1:hover{
border-color:#777;
}
.title{
position: relative;
text-align: center;
margin-top:25px;
font-family: Monospace;
}
@media screen and (max-width:928px){
div.Grid1 {
width:308px;
margin:0 auto;
}
}
@media screen and (max-width:487px){
div.Gallery1{
width:100%;
}
div.Grid1{
width:90%;
}
.title{
margin:25px;
}
}
.Grid1{
height: auto;
position: relative;
}
.content{
height:100%;
margin: 0;
padding: 0;
position: relative;
}
媒体查询
@media screen and (max-width:928px){
div.Grid1 {
width:308px;
margin:0 auto;
}
}
@media screen and (max-width:487px){
div.Gallery1{
width:100%;
}
【问题讨论】:
-
你需要将
float:left设置为div, -
嗨,你指的是什么 div :)
-
网格,标题,类似重叠
-
嗨,当我向标题、网格等内容添加左浮动时,它会导致内容不居中对齐,这可能有助于您在环境中启动代码以了解我的意思 :)
-
好的,只需删除
float:left并添加display:inline-block和较小的设备使用display:block
标签: html css grid footer responsive