0

I try to set jumbotron to be responsive on mobile device it so hard to me.

.jumbotron {
  background-image: url("../images/cover.fw.png");
  background-color: transparent;
  margin-bottom: 0;
  height: 100vh;
  background-repeat: no-repeat;
  background-position: center;
  -webkit-background-size: cover;
  background-size: cover;
}
<header>

  <div class="jumbotron">

  </div>
</header>

Desktop View:

Desktop View

Phone View:

Phone View

I need help to accomplish this task.

m4n0
  • 29,823
  • 27
  • 76
  • 89
Fx Crypto
  • 15
  • 2

3 Answers3

1

If you want to make the image responsive without cutting the sides, set "background-size: contain".

.jumbotron {
  background-image: url("https://i.stack.imgur.com/LmAwL.png");
  background-color: transparent;
  margin-bottom: 0;
  height: 100vh;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
<header>
  <div class="jumbotron"></div>
</header>
Akshaya K T
  • 185
  • 2
  • 8
0

make the background-size: contain instead of cover in the media query and change the height according to the screen in media screen and it works fine

Gurmatpal
  • 134
  • 8
0

Changing background-size from cover to contain will solve the problem.

.jumbotron {

  /* other properties */

  background-size: contain;
  -moz-background-size: contain;
}

Info:

contain - Resize the background image to make sure the image is fully visible.

cover - Resize the background image to cover the entire container, even if it has to stretch the image or cut a little bit off one of the edges

Vishnu Baliga
  • 413
  • 6
  • 13