aptbs85
aptbs85

Reputation: 101

Add background image in Bootstrap row

I would like to insert a full-width background image on this part of my page. Could someone please tell me which css rule i should follow? Because as far as i know you canot insert a background image inside a row. thanks

    <header>
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <img class="img-responsive" src="img/profile.png" alt="">
                    <div class="intro-text">
                        <span class="name">HEADING</span>
                        <hr class="star-light">
                        <span class="skills">TEXT</span>
                    </div>
                </div>
            </div>
        </div>
    </header>

Upvotes: 10

Views: 60994

Answers (2)

tao
tao

Reputation: 90287

When you want to add a background image, <img> is not the way to go. Use the background-image property.

<header>
  <div class="container">
    <div class="row" 
         style="background:transparent url('img/profile.png') no-repeat center center /cover">
      <div class="col-lg-12">
        <div class="intro-text">
          <span class="name">HEADING</span>
          <hr class="star-light">
          <span class="skills">TEXT</span>
        </div>
      </div>
    </div>
  </div>
</header>

Please note that adding inline style is not recommended, I used it demonstrative here. The proper way to style your div would be to add a specific class or an ID to it and style it inside your CSS files.

In the snippet above I used the background shorthand property to set the background-image. This shorthand allows setting background color, image, repeat, origin, clip, position and size in a single declaration. You can skip any of them, but size must be prefixed with a / and come right after position.

Upvotes: 17

OmerM25
OmerM25

Reputation: 253

You can set in your css file the background-image: url('img.png') property to define it.

For more options take a look here.

Upvotes: 0

Related Questions