css - Div 中的背景图像在左侧而不是右侧正确显示

标签 css html

我有一个图像,用于在主要内容区域周围创建伪阴影边框。但是,它只会出现在内容的左侧,不会出现在右侧。我知道这不是图像大小的问题,因为我们为页脚使用了类似的图像(以创建盒装外观)。下面是该部分的 css,如果他们看到我需要更改、删除或添加的内容,谁能告诉我?我是做网络前端/设计的新手,所以如果您需要其他任何东西,请告诉我。谢谢

#main 
{
background-image: url('../../Content/Images/body_rpt.png');
clear: both;  /*add this so tabs go left! */
padding: 15px 15px 15px 30px; /*30px 30px 15px 30px; */
background-color: #fff;
/*border-radius: 4px 0 0 0;*/
-webkit-border-radius: 4px 0 0 0;
-moz-border-radius: 4px 0 0 0;
}

为了比较这里是页 footer 分,它工作正常

footer, 
#footer 
{
background-image: url('../../Content/Images/body_bot.png');
background-repeat: no-repeat;
background-color: #fff;
color: #999;
padding: 10px 0;
text-align: center;
line-height: normal;
margin: 0 0 30px 0;
font-size: .9em;
border-radius: 0 0 4px 4px;
-webkit-border-radius: 0 0 4px 4px;
-moz-border-radius: 0 0 4px 4px;
}

最佳答案

我没有看到任何会导致您的主要 bg 图像出现在右侧的东西...我要做的是创建两个单独的 div 说如果我有 body > wrapper > col1, col2,我会做body > wrapper > col1 (left border), col2, col3, col4 (right border) 如果我要为我的边框使用图像,我会将 col1 和 col4 设置为 1-2% 宽度。

另一种方法是使用 float ,还有一种方法是使用 CSS 阴影属性中的构建(我不知道你的边框是什么样子,使用 fiddelr???)。

如果我感觉真的很新,我会拍摄我的背景图像,在图像编辑器中打开它,将 body length + border(left) + border(right) 作为我的图像宽度,并在两侧设置边框并将其用作我的背景(静态图像方法)。

关于css - Div 中的背景图像在左侧而不是右侧正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14409318/

相关文章:

javascript - 分页: How to limit number of pages on small screen devices

html - Bootstrap 在中断后删除同一行中列之间的空格

jquery - jssor slider 的箭头位置错误

javascript - 如何在当前滚动位置垂直居中对话框

javascript - Jquery .on 事件未在 Chrome 中触发

javascript - 如果 ng-model 为真 AngularJS 则滚动到元素 ID

html - 左边有一些文字的一行

javascript - Jquery Mobile Filter系统,无法隐藏多个div

html - 从范围动态设置的 Angularjs 属性在 IE7 中不起作用

jquery - 基于中心图像水平对齐 Div