-1

How can I prevent my background from jumping around? I want to have a red line in the end of my background but when I hover on the article, it's jumping around.

div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    margin-left: 20px;
    font-weight: 500;
    color: white;
    font-size: 20px;
    line-height: 21px;
}

.big-column {
    height: 396px;
    width: 311px;
    background-size: cover;
    box-sizing: border-box;
    background-image: url("https://image.freepik.com/free-vector/modern-technological-elements-with-transparent-background_1035-7108.jpg");
}

.big-column:hover {
    border-bottom: 5px solid #e60000;
    text-decoration: underline;
    color: white;
}
<article class="big-column big-column-1">
    <div class="column-description">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
    </div>
</article>
M0nst3R
  • 5,186
  • 1
  • 23
  • 36
Djaangoo
  • 5
  • 5

4 Answers4

1

Include the border on .big-column and set its color to transparent. On :hover you can then change the color to what you want.

div {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  margin-left: 20px;
  font-weight: 500;
  color: white;
  font-size: 20px;
  line-height: 21px;
}

.big-column {
  height: 396px;
  width: 311px;
  background-size: cover;
  box-sizing: border-box;
  background-image: url("https://image.freepik.com/free-vector/modern-technological-elements-with-transparent-background_1035-7108.jpg");
  border-bottom: 5px solid transparent;
}

.big-column:hover {
  border-color: #e60000;
  text-decoration: underline;
  color: white;
}
<article class="big-column big-column-1">
  <div class="column-description">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
  </div>
</article>
sol
  • 22,311
  • 6
  • 42
  • 59
0

Change border-bottom to box-shadow:

div{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  margin-left: 20px;
  font-weight: 500;
  color: white;
  font-size: 20px;
  line-height: 21px;
}

.big-column {
  height: 396px;
  width: 311px;
  background-size: cover;
  box-sizing: border-box;
  background-image: url("https://image.freepik.com/free-vector/modern-technological-elements-with-transparent-background_1035-7108.jpg");
}

.big-column:hover {
  box-shadow: inset 0 -5px 0 #e60000;
  text-decoration: underline;
  color: white;
}
<article class="big-column big-column-1">
  <div class="column-description">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
  </div>
</article>
Sergey Sklyar
  • 1,902
  • 1
  • 15
  • 27
0

All you need to do is change the box-sizing of your .big-column class to content-box.

M0nst3R
  • 5,186
  • 1
  • 23
  • 36
-1

i added position: fixed; on your background class, check it out. i think this should work!

 
  div{
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    margin-left: 20px;
  font-weight: 500;
    color: white;
    font-size: 20px;
    line-height: 21px;
  }

.big-column {
  height: 396px;
  width: 311px;
  position: fixed;
  background-size: cover;
  box-sizing: border-box;
  background-image: url("https://image.freepik.com/free-vector/modern-technological-elements-with-transparent-background_1035-7108.jpg");
}
.big-column:hover {
  border-bottom: 5px solid #e60000;
  text-decoration: underline;
  color: white;
}
<article class="big-column big-column-1">
                  <div class="column-description">

                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
                    
                  </div>


            </article>
MultiDutch
  • 36
  • 8