【发布时间】:2017-04-22 18:14:09
【问题描述】:
我放置了一个绿色的 PNG 图像作为 div 的背景,它看起来像这样:
我使用 CSS hack 来将文本保留在绿色背景内。所以这是我该部分的代码:
#aboutprocess {
background: url("../img/tech_bg.png") no-repeat left top;
width: 100%;
background-size: cover;
}
#aboutprocess .container {
padding-top: 32.6316%;
position: relative;
}
#aboutprocess .row {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
#aboutprocess p {
color: #ffffff;
text-align: center;
}
<section id="aboutprocess">
<div class="container">
<div class="row">
<div class="col-md-8 ">
<p class="text-center">Our agile team continuously delivers working software and empowers your organization to embrace changing requirements.</p>
<button type="button" class="btn btn-link center-block white" role="link" type="submit" name="op" value="Link 2">about our process</button>
</div>
<!--end col-md-8 col-md-offset-2-->
</div>
<!--end row -->
</div>
<!--end container-->
</section>
<!--end aboutprocess-->
我想用 SVG 文件替换 PNG,我在 CSS 中唯一更改的是文件扩展名:
#aboutprocess {
background: url("../img/tech_bg.svg") no-repeat left top;
width: 100%;
background-size: cover;
}
但是当我在浏览器中预览时,我再也看不到背景了:
我做错了什么?您可以看到带有PNG背景图像here的演示页面。
【问题讨论】:
-
您能否也发布您的 SVG 文件。
-
我用 Dropbox 链接更新了我的原始帖子。
标签: html css svg background-image