My CSS background-image is not is working

My CSS background-image is not is working
0

#1

Tell us what’s happening:

please guys help me am stuff here. I want to put a background image through CSS but its not working but all of the other images are worked perfectly fine.
but this “background-image: url(”./img/grass.jpg");" is not working.
Your code so far

<!DOCTYPE html>
<html lang="en">
  <head>
      <link rel="stylesheet" type="text/css" href="main.css" >
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA" content="ie=edge">
    <title>the glorious</title>
  </head>
  <body>
    <header class="showcase">
      <div class="content">
          <div class="title">
            <h1>This is a church website</h1>
          </div>
          <div class="text">
         <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
       </div>
          </div>
        <div class="branding">
          <h1><span class="light"> glorious</span> church</h1>
        </div>
        <nav>
          <ul>
            <li class="current"><a href="#">home</a></li>
            <li><a href="#">about</a></li>
            <li><a href="#">Service</a></li>
          </ul>
        </nav>
      </div>
    </header>
    <section id="Service">
      <div class="boxes center">
    <div class="container">
      <div class="box">
<img width="250" src="./img/grass.jpg">
<h3>heading one</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      </div>
    </div>
<div class="container">
  <div class="box">
    <img width="250" src="./img/cass.jpg">
    <h3>Heading two</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  </div>
</div>
<div class="container">
  <div class="box">
    <img width="250" src="./img/group.jpg">
    <h3>Heading three</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  </div>
</div>
</div>
</section>
<!-- About -->
<section class="about">
  <div class="boxes-2 center">
    <div class="container">
      <div class="box">
<img width="250" src="./img/grass.jpg">
<h3>About us</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      </div>
    </div>
  </div>
</section>
    <footer class="center ">
<p>The glorious church, copyright &copy; 2018</p>
    </footer>
  </body>
</html>
body{
  background: rgb(0, 0, 0, 0.9);
  margin: 0;
  color: #fff;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.showcase::after{
  height: 100vh;
  width: 100%;
  background-image: url("./img/grass.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}
.container{
  max-width: 960px;
  margin: auto;
  overflow: hidden;
  padding: 4rem 1rem;
}
.boxes{
  display: grid;
  grid-gap: 20px;
  grid-template-columns: repeat(3, 1fr);
}

.boxes-2{
  display: grid;
  grid-gap: 20px;
  grid-template-columns: repeat(1, 1fr);
  background:#f4f4f4;
  color: #333;
}
.center{
  text-align: center;
  margin: auto;
}[](http://)

#2

Pseudo classes before and after won’t show up unless they have some content even if that content is "".

You’ll need to add this to your css style content:""

.showcase::after{
  height: 100vh;
  width: 100%;
  background-image: url("https://thecanyonmalibu.com/wp-content/uploads/marijuana-1.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
  content:"";
}

#3

@alhazen1 thank you. but I still have an issues. I wanted the photo to be blur and if you hover on it is suppose bright but it’s not working. below are my code:

.showcase::after{
  content:"";
  height: 100vh;
  width: 100%;
  background-image: url("/img/code.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
  filter: blur(10px);
  -webkit-filter: blur(10px);
  transition: all 1000ms;
}

.showcase:hover::after{
  filter: blur(0px);
  -webkit-filter: blur(0px);
}

#4

Works for me, just remember the hover is on the element, not the pseudo element, so it will un-blur when you hover on .showcase, not just when you hover on the pseudo element.

Is there a reason why you are using a pseudo element?


#5

@lasjorg there no reason for it, am just trying experiment things to see how they work. I try running the codes on codepen its work perfectly fine. but misbehaving on my local machine, I don’t know the reason for that. am using atom as my editor and firefox and chrome to run the codes. please do have any idea what maybe the case or issue? thank you.


#6

I can’t possibly know why it’s not working on your local system, I would say to double check your code is the same. One random guess I can make is that maybe you have the hover on the pseudo element and not the actual element.

/* Needs to be like this */
.showcase:hover::after

/* Not like this */
.showcase::after:hover

#7

@lasjorg alright, thanks a lot for your time, I really appreciate it.