只有当屏幕尺寸等于我的默认屏幕分辨率时,我的div工作正常(占据所有区域)。否则我得到这个
如何使其响应屏幕大小调整?
ul{
list-style: none;
}
header{
width: auto;
background: url(pictures/heading-zebras-2.png) no-repeat 50% 0;
-webkit-background-size: cover;
background-size: cover;
height: 450px;
}
header h1{
float: left;
background-color:rgba(0,0,0,0.5);
padding: 40px 0 34px 43px;
width: 437px;
}
.tel {
display: inline-block;
background-color:rgba(0,0,0,0.5);
height: 60px;
padding: 30px 87px 0 0;
width: cover;
}
.tel li {
list-style-type: none;
display: inline;
}
.tel a{
font: 28pt/0.64 "Consolas", Arial, Helvetica, sans-serif;
color: white;
padding: 0 0 0 50px;
font-size: 87.5%;
}

<header>
<div><h1><a href="homepage.html"><img src="pictures/header-banner-text.png" alt="banner"></a></h1></div>
<div class="tel">
<nav>
<ul>
<li><a href=".html" title="">AMERICAS</a></li>
<li><a href=".html" title="">AFRICA</a></li>
<li><a href=".html" title="">EUROPE</a></li>
<li><a href=".html" title="">AUSTRALIA</a></li>
<li><a href=".html" title="">ASIA</a></li>
</ul>
</nav>
</div>
</header>
&#13;
答案 0 :(得分:2)
正是您的固定h1
宽度造成了这个问题。如果您正在进行响应式设计,请尝试尽可能少地使用固定值。
html,
body {
min-height: 100%;
height: 100%;
width: auto;
padding: 0;
margin: 0;
}
ul {
list-style: none;
}
header {
width: 100%;
background: url(pictures/heading-zebras-2.png) no-repeat 50% 0;
-webkit-background-size: cover;
background-size: cover;
height: 450px;
display: flex;
}
#banner-div {
flex: 1;
display: inline-block;
background-color: rgba(0, 0, 0, 0.5);
}
header h1 {
width: 100%;
padding: 40px 0 34px 43px;
float: left;
}
.tel {
flex: 4;
height: 60px;
width: 100%;
display: inline-block;
padding: 30px 87px 0 0;
background-color: rgba(0, 0, 0, 0.5);
}
.tel li {
list-style-type: none;
display: inline;
}
.tel a {
font: 28pt/0.64 "Consolas", Arial, Helvetica, sans-serif;
color: white;
padding: 0 0 0 50px;
font-size: 87.5%;
}
<header>
<div id="banner-div">
<h1>
<a href="homepage.html">
<img src="pictures/header-banner-text.png" alt="banner">
</a>
</h1>
</div>
<div class="tel">
<nav>
<ul>
<li><a href=".html" title="">AMERICAS</a></li>
<li><a href=".html" title="">AFRICA</a></li>
<li><a href=".html" title="">EUROPE</a></li>
<li><a href=".html" title="">AUSTRALIA</a></li>
<li><a href=".html" title="">ASIA</a></li>
</ul>
</nav>
</div>
</header>
答案 1 :(得分:0)
如果我很清楚你想要实现的目标,只需采取以下措施:
ul{
list-style: none;
}
.all {
background-color:rgba(0,0,0,0.5);
}
header{
width: auto;
background: url(pictures/heading-zebras-2.png) no-repeat 50% 0;
-webkit-background-size: cover;
background-size: cover;
height: 450px;
}
header h1{
padding: 40px 0 34px 43px;
width: 437px;
}
.tel {
display: inline-block;
height: 60px;
padding: 30px 87px 0 0;
width: cover;
}
.tel li {
list-style-type: none;
display: inline;
}
.tel a{
font: 28pt/0.64 "Consolas", Arial, Helvetica, sans-serif;
color: white;
padding: 0 0 0 50px;
font-size: 87.5%;
}
<header>
<div class="all">
<div>
<h1>
<a href="homepage.html"><img src="pictures/header-banner-text.png" alt="banner"></a>
</h1>
</div>
<div class="tel">
<nav>
<ul>
<li><a href=".html" title="">AMERICAS</a></li>
<li><a href=".html" title="">AFRICA</a></li>
<li><a href=".html" title="">EUROPE</a></li>
<li><a href=".html" title="">AUSTRALIA</a></li>
<li><a href=".html" title="">ASIA</a></li>
</ul>
</nav>
</div>
</div>
</header>