Responsive background-image

Asked

Viewed 41 times

1

hello, I have a problem in the responsive part of my site where the background image is cut when the site is on mobile, I would like to know how to adjust the image so that it looks the same on the monitor and mobile

.intro-content-bike {
  background: url(../img/dummy/bike.jpg) top center fixed;
  padding: 200px 0 60px;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  height: 696px;
  width: 100%;
  z-index: -2;
}

.intro-content-bike .mask {
  background: rgba(0, 0, 0, 0.3);
  background-size: cover;
  width: 100%;
  height: 42vw;
  position: relative;
  top: -5vw;
}

.simula {
  position: relative;
  top: 6vw;
}

.cotacao {
  position: relative;
  top: 6vw;
}
<section id="intro" class="intro">
  <div class="overlay"></div>
  <div class="intro-mask">
    <div class="intro-content-bike">
      <div class="container mask" id="mask-mobile">

        <div class="row">
          <div class="col-lg-6 col-md-6 col-sm-6 simula" id="simulacao">
            <div class="wow fadeInDown" data-wow-offset="0" data-wow-delay="0.1s">
              <h2 class="h-ultra" style="color:white;">SEGURO PARA BIKES</h2>
            </div>
            <div class="wow fadeInUp" data-wow-offset="0" data-wow-delay="0.1s">
              <h6 class="h-light" style="color:white;">Proteção completa para bicicletas de alta performance contra os principais riscos do dia a dia. </h6>
            </div>
            <div>
              <div class="wow fadeInRight" data-wow-delay="0.1s">

                <p class="text-center wow bounceIn" data-wow-delay="0.4s">
                  <button data-toggle="modal" data-target="#myModal" class="btn btn-skin btn-lg btn-cotacao" id="btn-simula" target="_blank">Faça uma simulação <i class="fa fa-angle-right"></i></a>
                    </p>
                  </div>
             </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 cotacao" id="env-msg">
                <div class="form-wrapper">
                  <div class="wow fadeInRight" data-wow-duration="2s" data-wow-delay="0.2s">

                    <div class="panel panel-skin">
                      <div class="panel-heading">
                        <h3 class="panel-title"><span class="fa fa-pencil-square-o"></span>Envie a sua mensagem </h3>
                      </div>
                      <div class="panel-body">
                       

                        <form action="email-bike.php" method="post" role="form" class="contactForm lead" id="form-bike">
                          <div class="row">
                            <div class="col-xs-6 col-sm-6 col-md-6">
                              <div class="form-group">
                                <label>Nome</label>
                                <input type="text" name="first_name" id="first_name" class="form-control input-md" data-rule="minlen:3" data-msg="Please enter at least 3 chars">
                                <div class="validation"></div>
                              </div>
                            </div>
                            <div class="col-xs-6 col-sm-6 col-md-6">
                              <div class="form-group">
                                <label>Telefone</label>
                                <input type="text" name="telefone" id="telefone" class="form-control telefone" placeholder="(11) 99999-9999" maxlength="15">
                                <div class="validation"></div>
                              </div>
                            </div>
                          </div>

                          <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12">
                              <div class="form-group">
                                <label>E-mail</label>
                                <input type="email" name="email" id="email" class="form-control input-md" data-rule="email" data-msg="Please enter a valid email">
                                <div class="validation"></div>
                              </div>
                            </div>
                            <div class="col-xs-12 col-sm-12 col-md-12">
                              <div class="form-group">
                                <label>Mensagem</label>
                                <textarea type="textarea" name="mensagem" id="mensagem" class="form-control input-md" 
                                data-rule="required" data-msg="A mensagem é obrigatória" style="height: 76px; color: white;"></textarea>
                                <div class="validation"></div>
                              </div>
                            </div>
                          </div>

                          <input type="submit" value="Enviar" class="btn btn-skin btn-block btn-lg btn-env" id="btn-msg">

                          <div class="alert alert-success" id="exito" style="z-index: 100000; display: none; width: 69%; height: 4vw; position: relative; left: 6vw; top: 1vw; background-color: rgba(255,255,255,.1); border: solid 3px #3bd39b; color: #3bd39b;">Mensagem enviada com sucesso!</div>
                        <div class="alert alert-danger" id="deuErrado" style="z-index:100000;display: none; width: 100%;">Erro: a mensagem não pode ser enviada!</div>

                        </form>
                      </div>
                    </div>

                  </div>
                </div>
              </div>
          </div>
          </div>
        
     </div>
        </div>
      
    </section>

  • Post the images somewhere so your question makes sense

  • Hello how do I do it ?? First time q I use stackoverflow

  • 1

    In addition to the media queries that the friend has already mentioned, it is interesting to have 2 images at least, but recommended 3. You use 1 for larger resolutions, another for medium ones and another for smaller resolutions, which is your case. This is because a full hd image with dimensions for a monitor, is very impaired in mobile phones, losing a lot of quality and even affecting the element that this is.

  • got I’ll try to make a smaller image, but I can change them with css by putting another backgroud-image in @media of the exact size q ??

  • @lelis419 Yes, just change the url path when you pass the background to the image you want to use in @media

1 answer

1

You’re not setting the responsiveness in your CSS code, try adding this:

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }

// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }

And pass the code you want between the brackets, and set the min-widht according to the minimum pixels you want for that size.

  • then I had already tried to do what you said, but the result was the same, the image is still cut in mobile

  • Did you set other values when you posted to @media? Lower values?

  • then I did not define, but what values you refer, because the width is as 100% and the height in my view would not interfere in the point I want

Browser other questions tagged

You are not signed in. Login or sign up in order to post.