Html 当我还原浏览器时,如何阻止我的页面元素收缩?
我知道这一定很简单,但我找不到任何适合我的解决方案。当我还原浏览器时,我的所有页面元素都会移动到不合适的位置并收缩,我希望它们保持在相同的位置并保持其大小 以下是我目前的代码:Html 当我还原浏览器时,如何阻止我的页面元素收缩?,html,css,Html,Css,我知道这一定很简单,但我找不到任何适合我的解决方案。当我还原浏览器时,我的所有页面元素都会移动到不合适的位置并收缩,我希望它们保持在相同的位置并保持其大小 以下是我目前的代码: <!DOCTYPE html> <html> <head> <title> What's in the picnic basket? </title> <link href="home.css" type="text/css" rel="styl
<!DOCTYPE html>
<html>
<head>
<title> What's in the picnic basket? </title>
<link href="home.css" type="text/css" rel="stylesheet"/>
<head>
<body>
<div id="wrapper">
<div class="titlebutton">
<img src="images/Title.gif" id="titlebutton">
</div>
<div class="grass">
<img src="images/Grasspatch.gif" id="grass">
</div>
</div>
</body>
</html>
非常感谢那些帮助我的人,我是这样一个编码能手:p您需要更改css中的position属性。当某个图元固定后,其属性将相对于浏览器窗口。因此,在您的情况下,当元素被固定时,它们的大小将调整为浏览器窗口的百分比。通过将它们设置为绝对,它们将成为相对于第一个静态父对象的 发件人:
.titlebutton{
position: fixed;
etc...
}
.grass {
position: fixed;
etc...
}
.titlebutton{
position: absolute;
etc...
}
.grass {
position: absolute;
etc...
}
至:
.titlebutton{
position: fixed;
etc...
}
.grass {
position: fixed;
etc...
}
.titlebutton{
position: absolute;
etc...
}
.grass {
position: absolute;
etc...
}
如果您想让它们保持相同的大小,则需要将其宽度设置为不带% 例如:
.#grass{
height: 400px;
width: 400px;
}
如果您想让它们调整一点大小,但不超过特定的限制,您可以使用以下方法:
#grass{
height: 80%;
width: 80%;
min-width: 400px;
min-height: 400px;
}
固定的位置将使它们保持在屏幕上的位置。固定与顶部100左100将是100从顶部和左侧的屏幕角落
绝对值也不总是离顶部100,因为在滚动等操作后,绝对值会上升。如果没有一个答案符合您的需要,您应该尝试详细解释“缩小”的含义-可能一个包含您实际需要的模型的屏幕截图会有所帮助。