html - 背景里面的背景 - css

标签 html css

我有两张图片:

http://oi62.tinypic.com/xpwpwl.jpg http://i59.tinypic.com/b7hocy.jpg

我需要使用 image1 作为背景,我想在它上面放置 image2,它将成为我的时事通讯输入表单的背景。

到目前为止,我发现的方法是将第一张图片作为背景,将第二张图片作为另一个背景,效果很好,但在某些分辨率下,image2(inputbackground) 会移动到不同的位置,我希望它保持不变几乎所有分辨率都处于相同位置。

这是我的代码:

HTML:

<div class="bgall">
    <div class="inputcontainer">
        <label>
            <input type="text" placeholder="Type your email" />
        </label>            
    </div>
</div>

CSS:

.bgall {
    background-image: url('../img/image1.jpg');
    background-repeat: no-repeat;
    background-position: center top;
    background-size: contain;
    height:564px;
    max-width: 100%;
    margin-bottom: 30px;
}

.inputcontainer {
    background-image: url('../img/image2.jpg');
    background-repeat: no-repeat;
    background-position: center top;
    background-size: contain;
    margin-top: 25%;
    margin-right: 19.5%;
    width: 250px;
    height: 93px;
    float: right;
}

label {
    padding-left: 24px;
    padding-top: 60px;
    position: absolute;
}

最佳答案

您很可能需要将 .inputcontainer 中的 margin 的相对值更改为绝对值。

margin-top: 25%;
margin-right: 19.5%;

类似于

margin-top: 250px;
margin-right: 195px;

或适合您图像的值。

关于html - 背景里面的背景 - css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26845498/

相关文章:

javascript - 无法将选定的下拉列表值推送到 javascript 数组中( meteor js)

javascript - 确定中心

css - CSS Sprite 菜单按钮与 CSS 之间的空间

javascript - jQuery 可排序 - 尝试排序时 div 折叠

html - 并排放置div ...我读过的任何内容都没有用

javascript - 点击事件仅在移动设备上第二次有效,但在桌面上正常

html - 如何使 div 的高度响应?

HTML 表格 - 更改列中单个单元格的宽度

html - 如果我使用 "cursive"或 "fantasy"字体系列,表情符号仅显示在 Chrome 上

Css 使用 jquery ui 并排放置列表