[英]Issue with repeat-x in CSS
Repeat-x property for CSS is not working as required. CSS的Repeat-x属性无法按要求工作。
I have a 50px image (to be used as background image). 我有一个50px的图像(用作背景图像)。
I take a 200px div and set the 50px image as background with repeat-x css property. 我采用200px的div并将50px的图像设置为具有repeat-x css属性的背景。
The problem I am facing is 4 images (4 * 50px = 200px) are correctly drawn and a little portion of the image is also drawn at the end. 我面临的问题是正确绘制了4张图像(4 * 50px = 200px),并且最后还绘制了图像的一小部分。 As I think this extra portion should not be drawn.
我认为不应提取此额外部分。 Please help.
请帮忙。
css property: CSS属性:
{
width:200px;
height:27px;
position:absolute;
background:url(./img/common/bg_grid.jpg) repeat-x left top;
background-size:50px 27px;
}
from above link you may find correct background image 从上面的链接中,您可能会找到正确的背景图片
There is a certain level of margin
or padding
that is inheriting its default value from the nested/parent elements. 有一定程度的
margin
或padding
从嵌套/父元素继承其默认值。 You need to reset them in order to get what you are looking for. 您需要重置它们才能获得所需的内容。
From your above code, For Instance, 根据您上面的代码, 例如,
{
width:200px;
height:27px;
position:absolute;
background:url(./img/common/bg_grid.jpg) repeat-x left top;
background-size:50px 27px;
padding:0; /* Reset values */
margin:0; /* Reset values */
}
EDIT: 编辑:
As per the updated fiddle provided by the OP, below is the solution. 根据OP提供的更新的小提琴,以下是解决方案。
The CSS Code Change: CSS代码更改:
<div style="width:900px;height:27px;position:absolute;top:150px;right:100px;background:url(http://i.stack.imgur.com/5ebiu.jpg) repeat-x left top;overflow:hidden;background-size:45px 28px;background-repeat: space;margin:0;padding:0"></div>
Hope this helps. 希望这可以帮助。
try this one 试试这个
.content
{
display:block;
position:relative;
float:left;
width:1000px;
background:#ccc;
height:300px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.