[英]Repeat-x doesn't work - css
I have one problem with repeat-x. 我对repeat-x有一个问题。 My css code is this:
我的CSS代码是这样的:
#header {
}
#header_left {
background:url("../img/header_l.png") no-repeat;
float:left;
width:341px;
height:258px;
}
#header_content {
background:url("../img/header_c.png") repeat-x;
width:32px;
height:258px;
float:left;
}
#header_right {
background:url("../img/header_r.png") no-repeat;
float:right;
width:341px;
height:258px;
}
And html code: 和html代码:
<div id="header">
<div id="header_left"></div>
<div id="header_content"></div>
<div id="header_right"></div>
</div>
But image header_c.png repeats only once. 但是图片header_c.png只重复一次。 How can I fix this problem?
我该如何解决这个问题?
Here is the screenshot: http://i.stack.imgur.com/mo0JW.png , header_c.png is repeating once and then leaving empty space. 这是屏幕截图: http ://i.stack.imgur.com/mo0JW.png,header_c.png重复一次,然后留出空白。
也许您的意思是repeat-y
,即查看HTML元素的尺寸。
If I understand correctly, your error is that between the central and right blocks obtained by the gap. 如果我理解正确,那么您的错误就是由间隙获得的中央和右侧块之间的错误。 You can fix this by setting the right block
float: left
or change width of center block. 您可以通过将右侧块的
float: left
设置为float: left
来解决此问题,或者更改中心块的宽度。
jsfiddle - my example with your error. jsfiddle-我的错误示例
jsfiddle - fix with float: left
jsfiddle-使用
float: left
修复float: left
jsfiddle - fix with exact size of center block jsfiddle-修复中心块的确切大小
May be you should try this 也许你应该试试这个
#header {
margin: 0 auto;
height:auto;
width:auto;
padding:0px;
}
#header_left {
background:url("../img/header_l.png") no-repeat left top;
width:341px;
height:258px;
}
#header_content {
background:url("../img/header_c.png") repeat-x left top;
width:32px;
height:258px;
}
#header_right {
background:url("../img/header_r.png") no-repeat left top;
width:341px;
height:258px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.