【发布时间】:2016-01-12 11:09:57
【问题描述】:
我已经找到了如何在彩色背景上制作图像,但当你有两个时却没有。我只想将 一个 图像居中在屏幕/页面的中间,并且我希望它随着窗口大小而缩小。
body {
font-family: 'Titillium Web', sans-serif;
}
#top,
#bottom {
background: url('http://uxrepo.com/static/icon-sets/zocial/svg/chrome.svg') no-repeat center center;
background-size: cover;
position: absolute;
left: 0;
right: 0;
height: 50%;
}
#top {
top: 0;
background-color: #ff0000;
}
#bottom {
bottom: 0;
background-color: #fff38f;
}
.header-container {
height: 130px;
width: 100%;
margin: 0 auto;
position: absolute;
top: 130px;
}
.header {
text-align: center;
line-height: 16px;
font-size: 48px;
font-weight: 400;
color: #ffffff;
}
.footer-container {
height: 130px;
width: 99%;
margin: 0 auto;
position: absolute;
bottom: 0;
}
.footer {
text-align: center;
line-height: 16px;
}
.img {
position: absolute;
width: 100%;
}
<body>
<div id="top">
<div class="header-container">
<div class="header">
SOME TITLE
</div>
</div>
</div>
<div id="bottom">
<div class="footer-container">
<div class="footer">
some text
<br>
<br>some text
<br>some text
<br>some text
</div>
</div>
</div>
</body>
有谁知道如何使这个结果变得简单?
【问题讨论】:
-
你能再解释一下吗?我不明白想要的结果以及当前代码有什么问题?
-
上面的结果将图像分成背景的两部分,因为我在#top, #bottom {...} 中有它,但我希望只有一张图像出现在屏幕上并居中在页面中间。
-
所需结果的图像会很有帮助,并且会增加请求的清晰度。
-
我在上面的帖子中添加了一个图片示例。
标签: html css image background layer