1

I'm struggling with getting my article promoting boxes to work as I want them to. The first box works as expected and I would like every box after that to work the same. However when you hover the image on any box after the first it dosn't trigger the hover class.

I think the problem lies in how the image class is selected when the box class is being hovered. I'd be gratefull for any help!

.ogse-container{
  margin-top: 150px;
  margin-left: 10px;
  position: relative;
  padding-top: 5px;
  padding-left: 45px;
  padding-right: 45px;
  width: 600px;
  height: 200px;
  background-color: #fff;
  border: 0px solid #666;
  box-shadow: 0px 0px 30px -5px #333;
  text-overflow: ellipsis;
}
.ogse-side{
  position: absolute;
  top: 0px;
  left: 0px;
  width: 45px;
  height: 100%;
  background-color: #a00;
}
.ogse-img{
  position: absolute;
  height:100px;
  width: 80%;
  left: 10%;
  top: -45px;
  z-index: -1;
  transition: top .2s;
}
.ogse-container:hover .ogse-img{
  top: -100px;
}


.ogse-header{
  text-align: center;
}
.ogse-para{
  text-align: center;
}
<div class="ogse-container">     
  <a href="http://www.swiftpeak.net/">
       <div class="ogse-img" style="background-image: url('http://c.directlyrics.com/img/upload/example-all-the-wrong-places-artwork-cover.jpg');">
     </div>
  </a>  
  <div class="ogse-side">
  </div>
  <a href="http://www.swiftpeak.net/">
     <h2 class="ogse-header">Article header</h2>
  </a>
  <p class="ogse-para">Some sample text about, some important stuff which I can't tell anyone just yet. So i'm just going to have this text be a big mystery.</p> 
</div>
<div class="ogse-container">
  <a href="http://www.swiftpeak.net/">
       <div class="ogse-img" style="background-image: url('http://c.directlyrics.com/img/upload/example-all-the-wrong-places-artwork-cover.jpg');">
     </div>
  </a>
  <div class="ogse-side">
  </div>
  <a href="http://www.swiftpeak.net/">
     <h2 class="ogse-header">Article header</h2>
  </a>
  <p class="ogse-para">Some sample text about, some important stuff which I can't tell anyone just yet. So i'm just going to have this text be a big mystery.</p>
</div>

2
  • 2
    Which browser are you testing in? The Snippet works for me in Chrome 53. Commented Sep 24, 2016 at 10:53
  • @bbodien I have the same browser and version. Try to hover the second box's image. That won't trigger the :hover class for the box unlike the first box. Commented Sep 24, 2016 at 11:05

1 Answer 1

1

I just restructured the HTML and edited the CSS a bit:

.ogse-container {
  position: relative;
  width: 690px;
}
.ogse-container-inner-side {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 45px;
  height: 100%;
  background-color: #a00;
}
.ogse-container-inner-img {
  position: absolute;
  height: 100px;
  width: 80%;
  left: 10%;
  top: -45px;
  transition: top .2s;
}
.ogse-container-inner-img div {
  height: 100%;
  width: 100%;
}
.ogse-container:hover .ogse-container-inner-img {
  top: -100px;
}
.ogse-container-inner-text {
  margin-top: 150px;
  position: relative;
  width: 600px;
  height: 200px;
  padding-top: 5px;
  padding-left: 45px;
  padding-right: 45px;
  background-color: #fff;
  border: 0px solid #666;
  box-shadow: 0px 0px 30px -5px #333;
  text-overflow: ellipsis;
}
.ogse-header,
.ogse-para {
  text-align: center;
}
<div class="ogse-container">
  <div class="ogse-container-inner-img">
    <a href="http://www.swiftpeak.net/">
      <div style="background-image: url('http://c.directlyrics.com/img/upload/example-all-the-wrong-places-artwork-cover.jpg');"></div>
    </a>
  </div>

  <div class="ogse-container-inner-text">
    <div class="ogse-container-inner-side"></div>
    <a href="http://www.swiftpeak.net/">
      <h2 class="ogse-header">Article header</h2>
    </a>
    <p class="ogse-para">Some sample text about, some important stuff which I can't tell anyone just yet. So i'm just going to have this text be a big mystery.</p>
  </div>
</div>

<div class="ogse-container">
  <div class="ogse-container-inner-img">
    <a href="http://www.swiftpeak.net/">
      <div style="background-image: url('http://c.directlyrics.com/img/upload/example-all-the-wrong-places-artwork-cover.jpg');"></div>
    </a>
  </div>

  <div class="ogse-container-inner-text">
    <div class="ogse-container-inner-side"></div>
    <a href="http://www.swiftpeak.net/">
      <h2 class="ogse-header">Article header</h2>
    </a>
    <p class="ogse-para">Some sample text about, some important stuff which I can't tell anyone just yet. So i'm just going to have this text be a big mystery.</p>
  </div>
</div>

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks alot, it's flawless!
Could you also explain why this works? I.E. the cause of the OP's problem, what was it?

Your Answer

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.