我正在研究需要响应的非常基本的一个页面布局。它包含一个大背景图像的 和绝对位于其周围的2-3个div。 http://www.reversl.net/demo/我使用绝对定位的原因是因为背景图像需要在高度上有所不同,但文本框需要始终位于与图像底部相同的距离处。绝对定位和媒体查询
我还需要在页面的右下角放置一个徽标。在桌面设备上查看时一切正常。但在智能手机上,由于屏幕较小,我需要使用媒体查询将徽标置于文本下方。现在问题出现了......因为文本div完全被定位......标志隐藏在较小的屏幕后面。我最初的想法是让徽标处于顶部的绝对位置,以便它始终出现在宽度为320px及以下的屏幕尺寸的文本框下方。然而,文本框将需要高度不同,所以我不能这样工作。
我的问题是...如何放置徽标,使其始终出现在320px宽和更低的屏幕尺寸的文本框下方(与文本框高度无关)?
#bg {
max-width: 100%;
margin: 0;
padding: 0;
position: relative;
}
#title {
margin: 0;
padding: 0;
color: #f0f0f0;
background: #333;
margin: 0;
padding: .5em 1em;
width: 250px;
position: absolute;
top: -2%;
text-align: center;
}
#content {
background: #333;
width: 250px;
position: absolute;
top: 85%;
padding: .5em 1em;
color: #888;
text-align: center;
border: 1px solid #444;
}
footer {
margin: 0;
padding: 0;
}
.logo {
float: right;
width: 50px;
height: 25px;
border: 1px solid #444;
text-align: center;
padding: .5em;
color: #666;
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
#title {top: -17%;line-height: 1;}
}
你有没有考虑过将所有东西都绝对放在手机版上,只是用你想要的方式放置物品,使用边距和填充? – 2012-08-02 13:38:41
@BillyMoat这可能是一个选项。这可能会很棘手,但由于背景图像的高度不同,但我一定会试一试。干杯! – Jedda 2012-08-03 13:42:20