Problems identifying mobile screen with css

Asked

Viewed 274 times

2

I’m trying to ride a box box of login responsive. Where he has .css for monitor screens and other for mobile. The problem is that the mobile phone is not working.

I make the following test:

@media only screen and (max-width: 550px) {

If I turn down the window on browser less than 550px the .css changes, but when I open the page on my iPhone 6 the check doesn’t work. As I identify the mobile screen with .css?

.box_login {
  position: relative;
  top: 20px;
  width: 400px;
  color: #666;
  border-radius: 4px;
  background: #FFFFFF;
  margin: auto auto 100px;
  overflow: hidden;
  padding: 0 0 50px 0;
}
.box_body {
  margin: 30px;
}
.box_login_header {
  background: #0091FF;
  position: relative;
  height: 185px;
  width: 100%;
  margin-bottom: 10px;
}
.cont-lock {
  width: 100%;
  height: 150px;
  position: relative;
}
.cont-lock-img {
  margin-top: 25px;
  margin-left: 62px;
}
.cont-lock::after {
  content: '';
  width: 0;
  height: 0;
  display: block;
  position: absolute;
  margin: auto;
  left: 0;
  right: 0;
  bottom: -35px;
  border: 7px solid rgba(0, 0, 0, 0);
  border-bottom-color: white;
}
.box_login h1 {
  margin-left: 20px;
  margin-top: 0;
  color: #cfd8dc;
  line-height: 35px;
}
.box_login button {
  width: 330px;
}
.box_login_footer {
  width: 100%;
  height: 45px;
  background: #0091FF;
  position: absolute;
  bottom: 0;
  color: #FFFFFF;
  text-align: center;
  padding: 10px 0 0 0;
}
@media only screen and (max-width: 550px) {
  .box_login {
    width: 95%;
  }
}
<div class="box_login">

  <div class="box_login_header">
    <div class="cont-lock">
      logo
    </div>
  </div>

  <div class="box_body">

    FORM
  </div>

  <div class="box_login_footer">
  </div>
</div>

1 answer

2


You have to enter the tag meta name="viewport"

<meta name="viewport" content="width=device-width, initial-scale=1">

She is responsible for, among other things, resizing the viewport layout.

In the content you specify attributes of the viewport and define its values by placing width=device-widthyou say that the rendering resolution of the viewport, relative to the width, will equal the resolution of the device.

Or, in the near future, by css:

@viewport {
    width: device-width;
}

"Future", because only those who have support CSS Device Adaptation is currently the Opera, IE11 and Edge14. CSS Device Adaptation - Can I Use.

  • Thank you very much, you helped me to ca****hahaha

Browser other questions tagged

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