gpt4 book ai didi

javascript - 防止浏览器变窄时左侧div滑出浏览器

转载 作者:太空宇宙 更新时间:2023-11-03 17:58:38 25 4
gpt4 key购买 nike

我希望记住它是响应式的。从右向左拖动我的浏览器时。 pic div 将被推出浏览器。我的内容没有正确居中吗?我不确定是否必须使用媒体查询。如果是这样我不知道。所以请为我详细说明。

CSS:

 body {
background-color: #333435;
padding: 0px;
margin: 0px;
}
.container {
height: 500px;
width:800px;
margin: -250px 0 0 -400px;
position: absolute;
left:50%;
top:50%;
}
.time {
text-align: center;
width: 100%;
margin: auto;
margin-bottom: -20px;
font-family:"Avant Garde", Avantgarde, "Century Gothic", CenturyGothic, "AppleGothic", sans-serif;
font-style: italic;
font-size: 100px;
color:#d6d6d6;
padding-top: 30px;
}
#date {
text-align: center;
width: 100%;
margin: auto;
font-family:"Avant Garde", Avantgarde, "Century Gothic", CenturyGothic, "AppleGothic", sans-serif;
color:#d6d6d7;
}
#main {
display: block;
width: 100%;
height: 346px;
margin-top: 35px;
}
.logo {
background-image: url('images/logo.png');
background-repeat: no-repeat;
float:left;
width: 25%;
height: 100%;
display: block;
}
.portaltext {
width:240px;
height:34px;
background-image: url('images/portal.png');
float: left;
clear: both;
position: relative;
top: 94px;
}
.divider {
background-color:#008000;
float:left;
width: 25%;
height: 100%;
}
#loginform {
background-color:#A52A2A;
float:left;
width: 25%;
height: 100%;
}

HTML:

<!doctype html>
<html>
<head>
<title>Portal</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>

<body>
<div class="container">
<div class="time">12:22 PM</div>
<div id="date">Friday, September, 12, 2014</div>
<div id="main">
<div class="logo">
<div class="portaltext"></div>
</div>
<div class="divider"></div>
<div id="loginform"></div>
</div>
</div>
</body>
</html>

截图:

Image

最佳答案

我从你的问题中可以理解的是,当你调整浏览器大小时,如果这是因为负边距而发生的问题,图像会被推出屏幕,你可以使用媒体查询解决它

@media screen and ( max-width:800px)
{
.container {

margin:0px;
left:0%;
}
}

我认为这会有所帮助,否则抱歉

关于javascript - 防止浏览器变窄时左侧div滑出浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25819291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com