我需要为中心div
加载背景图片。
HTML :
<div class="container">
<div class="row">
<div class="col-lg-12">text
<div class="row">
<div class="col-md-8 col-md-offset-2 col-sm-8 col-sm-offset-2 col-xs-8 col-xs-offset-2" style="background:red;color:white">TEXT with background image</div>
</div>
</div>
</div>
</div>
CSS :
@import url('http://getbootstrap.com/dist/css/bootstrap.css');
答案 0 :(得分:0)
将backgroud:url('url-to-your-image');
添加到div元素的内联样式
<div
class="col-md-8 col-md-offset-2 col-sm-8 col-sm-offset-2 col-xs-8 col-xs-offset-2"
style="background:red;color:white; background:url('url-to-your-image')"
>TEXT with background image</div>
答案 1 :(得分:0)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="background-image:url('paper.gif');">
<h1>Hello World!</h1>
</div>
</body>
</html>
这是设置背景图像的一种方法。
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#bgimg {
background-image: url('paper.gif');
}
</style>
</head>
<body>
<div id="bgimg">
<h1>Hello World!</h1>
</div>
</body>
</html>
这是另一种方法。希望它有所帮助!