0

I have a problem with a CSS background image that will not show, can anyone se why it will not show the image? i cant figure it out myself.

 <!-- Section: services -->
<section id="service" class="home-section text-center bg-gray">
 <div class="heading-about">
 <div class="container">
 <div class="row">
 <div class="col-lg-8 col-lg-offset-2">
 <div class="wow bounceInDown" data-wow-delay="0.4s">
 <div class="section-heading">
 <h2>SCHEMA!</h2>
 <i class="fa fa-2x fa-angle-down"></i>
 </div>
 </div>
 </div>
 </div>
 </div>
 </div>
<br>TEST<br>
 </div>
 </div>
 </div>
 </div> 
 </div>
</section>
<!-- /Section: services -->
.service {
width:100%;
position:relative;
background: url(../img/bg2.jpg) no-repeat top center;
}
emmanuel
9,61310 gold badges27 silver badges38 bronze badges
asked Feb 16, 2015 at 21:21
2
  • 1
    .service must be #service since service is an ID not a classname Commented Feb 16, 2015 at 21:25
  • Is the img a folder? Commented Feb 16, 2015 at 21:26

3 Answers 3

4

You want to use #service when referring to ID's of elements.

#service {
width:100%;
position:relative;
background: url(../img/bg2.jpg) no-repeat top center;
}

A good guide on css selectors can be found here.

answered Feb 16, 2015 at 21:26
Sign up to request clarification or add additional context in comments.

3 Comments

There are better sources than w3schools of all things (also called "w3fools" for a purpose), but your answer is better than mine because of adding a link. Well done!
Curious, why the hatred for w3schools? It is simple, but I think it displays things in a nice manner and is good for absolute beginners.
Oh, that is no hatred! It is just that they are imprecise and outdated sometimes which can lead to great confusion. I would recommend MDN instead: developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started/… Well written, precise and cross browser.
0

You define the top level element as:

<section id="service" class="home-section text-center bg-gray">

So you give it the id "service", not the class.

Therefore your css should be:

#service {
 width:100%;
 position:relative;
 background: url(../img/bg2.jpg) no-repeat top center;
}

Note the leading # instead of the ..

answered Feb 16, 2015 at 21:26

Comments

0

In my opinion in your CSS you refer to class ".service{..." instead of a id of section element. So you have to use "#service{..." instead of ".service {..."

answered Feb 16, 2015 at 21:33

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.