我想在Bootstrap中的背景图像

时间:2015-05-06 15:48:32

标签: html css twitter-bootstrap

帮我把图像放在背景中而不是背景色 我尝试过Bootstrap" img-responsive img-center" html标签,但它不会出现在文本和CSS" background-image:url(");"根本不工作

这是CSS:



header {
    text-align: center;
    color: #fff;
    background-color: #31353D;
}

header .container {
    padding-top: 74px;
    padding-bottom: 263px;
}

header .intro {
    font-family: 'Roboto', sans-serif;
    font-size: 2em;
    text-transform: uppercase;
     font-weight: 900;
     letter-spacing: 1px;  
}

header .subintro {
    font-family: 'Roboto', sans-serif;
    font-size: 0.8em;
    text-transform: uppercase;
    font-weight: 500;
}

Here is HTML

<header>
	<div class="container"> 
		<div class="row">
			<div class="col-lg-12">
				<div class="intro-text">
					<span class="intro" id="mainIntro">We will lead the way</span></br>
					<span class="subintro" id="secondIntro">We provide not better but best in the world</span></br>
					<button type="button" class="btn btn-default" id="introBtn">START YOUR JOURNEY</button>
				</div>
				</div>
			</div>
		</div>
	</div>
</header>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

background-image: url()设置

之后,将background-size: coverbackground-color添加到标头的css声明中

DEMO

header {
    text-align: center;
    color: #fff;
    background-color: #31353D;
    background-image: url(http://www.lorempixel.com/1000/1000);
    background-size: cover;
}

答案 1 :(得分:1)

这应该很简单

header {
    text-align: center;
    color: #fff;
    background-color: #31353D;
    background-image: url(http://lorempixel.com/output/abstract-q-g-640-480-8.jpg);
    /* or insert appropriate path to your image */
}

&#13;
&#13;
header {
    text-align: center;
    color: #fff;
    background-color: #31353D;
    background-image: url(http://lorempixel.com/output/abstract-q-g-640-480-8.jpg);
    /* or insert appropriate path to your image */
}

header .container {
    padding-top: 74px;
    padding-bottom: 263px;
}

header .intro {
    font-family: 'Roboto', sans-serif;
    font-size: 2em;
    text-transform: uppercase;
     font-weight: 900;
     letter-spacing: 1px;  
}

header .subintro {
    font-family: 'Roboto', sans-serif;
    font-size: 0.8em;
    text-transform: uppercase;
    font-weight: 500;
}

Here is HTML
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<header>
	<div class="container"> 
		<div class="row">
			<div class="col-lg-12">
				<div class="intro-text">
					<span class="intro" id="mainIntro">We will lead the way</span></br>
					<span class="subintro" id="secondIntro">We provide not better but best in the world</span></br>
					<button type="button" class="btn btn-default" id="introBtn">START YOUR JOURNEY</button>
				</div>
				</div>
			</div>
		</div>
	</div>
</header>
&#13;
&#13;
&#13;