【发布时间】:2014-07-26 12:34:43
【问题描述】:
编辑的问题如何在缩小浏览器时保持图像的高度调整大小?
好的,我已经尝试搜索了一段时间,但似乎无法在任何地方找到它。这就是我想要做的......
我的导航使用的是上传的图片,而不是 CSS 生成的导航菜单。
当我调整浏览器窗口大小时...我的背景使用以下方法正确调整大小:
body {
background: url('/images/background.jpg') no-repeat center center fixed;
background-color:#000000;
background-size: 70%;
}
至于我的导航图像...我已经让它们调整大小,但没有留在正确的位置...这是我的代码....80px 导航高度是问题...:
/* navigation */
nav {
position: relative;
top: 200px;
left: 10%;
max-width: 15%;
}
nav a {
display: block;
max-width: 191px;
height: 80px;
margin: 0;
padding: 0;
}
#homebutton {
background: url('/images/homebutton.png') no-repeat 0, 0;
background-size: contain;
}
#aboutbutton {
background: url('/images/aboutbutton.png') no-repeat 0, 0;
background-size: contain;
}
#storebutton {
background: url('/images/storebutton.png') no-repeat 0, 0;
background-size: contain;
}
#facebookbutton {
background: url('/images/facebookbutton.png') no-repeat 0, 0;
background-size: contain;
}
#contactbutton {
background: url('/images/contactbutton.png') no-repeat 0, 0;
background-size: contain;
}
这是我的意思的图片....第一个是全尺寸的浏览器...第二个是缩小尺寸的浏览器。
【问题讨论】:
-
您可能没有在正确的地方搜索 (Google)。至少有十几个类似的问题,都在这里。
-
看看
CSS3 Media Queries。此外,如果您有nav a: { width: 191px; height: 80px; display: block;,则无需将其添加到每个ID,因为它已经添加,请考虑DRY方法。 -
谢谢Nick R...效果很好...但仍然没有答案...虽然...现在我遇到了身高问题80px...有没有办法让它也可以调整?