简体   繁体   English

在特定位置重复CSS背景

[英]Repeat CSS background at certain position

I'm trying to get a background tile for a certain position, like so: 我正在尝试为特定位置获取背景图块,如下所示:

小样

I have the following CSS and dummy div under the body tag. 我在body标签下有以下CSS和虚拟div。

div#dummy {
    position: absolute;
    top: 200px;
    bottom: 0;
    left: 0;
    right: 0;
    background-image: url("data:image/png;base64....");      
}

However this doesn't reach the bottom despite specifying bottom 0. Any ideas? 但是,尽管指定了最低值0,但是它没有达到最低值。有什么想法吗? I think I may be going about this the wrong way. 我想我可能会走错路了。

You might want to make sure you are including a reset.css http://meyerweb.com/eric/tools/css/reset/ 您可能要确保包含一个reset.css http://meyerweb.com/eric/tools/css/reset/

You can then try setting the background property of the body itself, setting the position like so: 然后,您可以尝试设置主体本身的background属性,如下所示设置位置:

background: blue url('myimage.png') no-repeat left bottom;

The "blue" at the start specifies the colour of the top part of the image. 开始处的“蓝色”指定图像顶部的颜色。 The two properties at the end specify the background "position". 最后的两个属性指定背景“位置”。 Specifying bottom should make it glue to the bottom. 指定底部应使其粘在底部。

Then the height of the background image itself will determine how far up the tile it comes. 然后,背景图像本身的高度将确定其到瓷砖的高度。 You can use repeat-x instead of no-repeat if you want the background to tile horizontally.. 如果希望背景水平平铺,则可以使用repeat-x而不是no-repeat

One of many ways no doubt. 毫无疑问,这是多种方式之一。

it should work- 它应该工作-

html, body
{
    margin:0;
    padding:0;
    width:100%;
    height:100%;
} 
#bluePart
{
    height:30%;
    width:100%;
    background:#2A3BA6;
    border:solid 0px #000000;
}
#lowerTilePart
{
    height:70%;
    width:100%;
    background-image:url(images/bgImage.gif);
    background-repeat:repeat;
    border:solid 0px #FF0000;
}

the css style for html, body part is must. HTML的CSS样式,正文部分是必须的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM