当浏览器最小化或调整大小时,防止内容移动
Keep contents from shifting when browser is minimized or resized
我是新手,所以我遇到了这个问题,当浏览器最小化时,页面中的内容会移动。浏览器最小化时,包括logo在内的内容会移位,内容会移出蓝色透明背景。
这是我的 css 代码
#full-screen-background-image {
z-index: -999;
min-height: 100%;
min-width: 1300px;
width: 100%;
height: auto;
position: absolute;
top: 0;
left: 0;
}
.whole{
margin: 0px auto;
height: 1242px;
width: 1000px;
}
.clear{
margin: 0 auto;
clear: both;
}
.logo {
width: 460px;
height: 170px;
margin: 0 auto;
}
.fax {
margin: 0 auto;
width: 480px;
height: 110px;
margin-right: 267px;
}
.fax p {
color: white;
font-family: 'Istok Web', sans-serif;
font-size: 35px;
text-align:center;
float:left;
margin: 0 auto;
margin-top: 55px;
width: 394px;
}
.faxLogo{
float: left;
height:60px;
width: 60px;
margin: 0 auto;
margin-top: 40px;
margin-left: -385px;
}
.tel{
margin: 0 auto;
width: 480px;
height: 70px;
margin-right: 267px;
}
.telDetails{
float:left;
height: 10px;
}
.telLogo{
float: left;
height:60px;
width: 60px;
margin: 0 auto;
margin-top: -10px;
margin-left: 65px;
}
.tel p {
color: white;
font-family: 'Istok Web', sans-serif;
font-size: 35px;
text-align: center;
margin:0 auto;
margin-top: 10px;
margin-left: 10px;
}
.locationLogo{
float: left;
height: 60px;
width: 60px;
margin: 0 auto;
margin-left: 65px;
}
.location{
margin: 0 auto;
width: 500px;
}
.location p {
color: white;
font-family: 'Istok Web', sans-serif;
font-size: 35px;
float: left;
margin:0 auto;
margin-top: -35px;
margin-left: 160px;
line-height: 60px;
}
.detail1 {
margin: 0 auto;
text-align:center;
}
.detail1 p{
font-size: 45px;
font-family: 'Istok Web', sans-serif;
color:white;
text-align:center;
margin-left: 130px;
}
.detail2 {
font-size: 45px;
font-family: 'Istok Web', sans-serif;
color: white;
margin: 0 auto;
}
.detail2 p{
margin-top: -20px;
text-align:center;
margin-left: 45px;
}
这是我的HTML代码
<div class="clear" style="height: 445px;"></div>
<div class="whole">
<div class="logo"><img src="images/logo_3.jpg" /></div>
<div class="clear" style="height:50px;"></div>
<div class="detail1">
<p>TEXT</p>
</div>
<div class="detail2">
<p>TEXT</p>
</div>
<div class="clear" style="margin-top:-53px;"></div>
<div class="location">
<div class="locationLogo">
<img src="images/location.png" />
</div>
<div class="locationDetails">
<p style="width: 500px;">TEXT<br />TEXT<br />TEXT</p>
</div>
</div>
<div class="tel">
<div class="telLogo" style="width: 10px;">
<img src="images/tel.png" />
</div>
<div class="telDetails">
<p style="width: 365px;">TEXT</p>
</div>
</div>
<div class="fax">
<div class="faxLogo" style="width: 10px;">
<img src="images/fax.png" />
</div>
<div class="faxDetails">
<p style="width: 394px;">TEXT</p>
</div>
</div>
</div>
当 window 调整大小时,透明框中的内容会移动,但透明框是背景图像的一部分。使用石油钻井平台作为背景图片并将您的内容放在 div 中。像这样:
.box {
width: 100%;
height: auto;
background-color: rgba(0,0,255,0.5);
}
<div class="box">
<ul>
<li>SOME CONTENT HERE</li>
<li>SOME CONTENT HERE</li>
<li>SOME CONTENT HERE</li>
<li>SOME CONTENT HERE</li>
</ul>
</div>
您现在可以将 div 放在页面上您认为合适的任何位置。
我是新手,所以我遇到了这个问题,当浏览器最小化时,页面中的内容会移动。浏览器最小化时,包括logo在内的内容会移位,内容会移出蓝色透明背景。
这是我的 css 代码
#full-screen-background-image {
z-index: -999;
min-height: 100%;
min-width: 1300px;
width: 100%;
height: auto;
position: absolute;
top: 0;
left: 0;
}
.whole{
margin: 0px auto;
height: 1242px;
width: 1000px;
}
.clear{
margin: 0 auto;
clear: both;
}
.logo {
width: 460px;
height: 170px;
margin: 0 auto;
}
.fax {
margin: 0 auto;
width: 480px;
height: 110px;
margin-right: 267px;
}
.fax p {
color: white;
font-family: 'Istok Web', sans-serif;
font-size: 35px;
text-align:center;
float:left;
margin: 0 auto;
margin-top: 55px;
width: 394px;
}
.faxLogo{
float: left;
height:60px;
width: 60px;
margin: 0 auto;
margin-top: 40px;
margin-left: -385px;
}
.tel{
margin: 0 auto;
width: 480px;
height: 70px;
margin-right: 267px;
}
.telDetails{
float:left;
height: 10px;
}
.telLogo{
float: left;
height:60px;
width: 60px;
margin: 0 auto;
margin-top: -10px;
margin-left: 65px;
}
.tel p {
color: white;
font-family: 'Istok Web', sans-serif;
font-size: 35px;
text-align: center;
margin:0 auto;
margin-top: 10px;
margin-left: 10px;
}
.locationLogo{
float: left;
height: 60px;
width: 60px;
margin: 0 auto;
margin-left: 65px;
}
.location{
margin: 0 auto;
width: 500px;
}
.location p {
color: white;
font-family: 'Istok Web', sans-serif;
font-size: 35px;
float: left;
margin:0 auto;
margin-top: -35px;
margin-left: 160px;
line-height: 60px;
}
.detail1 {
margin: 0 auto;
text-align:center;
}
.detail1 p{
font-size: 45px;
font-family: 'Istok Web', sans-serif;
color:white;
text-align:center;
margin-left: 130px;
}
.detail2 {
font-size: 45px;
font-family: 'Istok Web', sans-serif;
color: white;
margin: 0 auto;
}
.detail2 p{
margin-top: -20px;
text-align:center;
margin-left: 45px;
}
这是我的HTML代码
<div class="clear" style="height: 445px;"></div>
<div class="whole">
<div class="logo"><img src="images/logo_3.jpg" /></div>
<div class="clear" style="height:50px;"></div>
<div class="detail1">
<p>TEXT</p>
</div>
<div class="detail2">
<p>TEXT</p>
</div>
<div class="clear" style="margin-top:-53px;"></div>
<div class="location">
<div class="locationLogo">
<img src="images/location.png" />
</div>
<div class="locationDetails">
<p style="width: 500px;">TEXT<br />TEXT<br />TEXT</p>
</div>
</div>
<div class="tel">
<div class="telLogo" style="width: 10px;">
<img src="images/tel.png" />
</div>
<div class="telDetails">
<p style="width: 365px;">TEXT</p>
</div>
</div>
<div class="fax">
<div class="faxLogo" style="width: 10px;">
<img src="images/fax.png" />
</div>
<div class="faxDetails">
<p style="width: 394px;">TEXT</p>
</div>
</div>
</div>
当 window 调整大小时,透明框中的内容会移动,但透明框是背景图像的一部分。使用石油钻井平台作为背景图片并将您的内容放在 div 中。像这样:
.box {
width: 100%;
height: auto;
background-color: rgba(0,0,255,0.5);
}
<div class="box">
<ul>
<li>SOME CONTENT HERE</li>
<li>SOME CONTENT HERE</li>
<li>SOME CONTENT HERE</li>
<li>SOME CONTENT HERE</li>
</ul>
</div>
您现在可以将 div 放在页面上您认为合适的任何位置。