blockhead
blockhead

Reputation: 431

Mobile view responsivenes for html form

On mobile view the form seems to be zoomed out, how do I make it fit to the screen. I am thinking of redoing it with flexbox, I have changed the margin also changed the width and the height but it still doesn't remedy the situation.

UPDATE: I added meta tags and it improved a bit, but it's still not zoomed in.

Current: enter image description here

What I want it to look like: This is what i want it to look like

body {
  background: #59ABE3;
  margin: 0
}

.form {
  width: 340px;
  height: 440px;
  background: #e6e6e6;
  border-radius: 8px;
  box-shadow: 0 0 40px -10px #000;
  margin: calc(50vh - 220px) auto;
  padding: 20px 30px;
  max-width: calc(100vw - 40px);
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
  position: relative
}

h2 {
  margin: 10px 0;
  padding-bottom: 10px;
  width: 180px;
  color: #78788c;
  border-bottom: 3px solid #78788c
}

input {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  background: none;
  outline: none;
  resize: none;
  border: 0;
  font-family: 'Montserrat', sans-serif;
  transition: all .3s;
  border-bottom: 2px solid #bebed2
}

input:focus {
  border-bottom: 2px solid #78788c
}

p:before {
  content: attr(type);
  display: block;
  margin: 28px 0 0;
  font-size: 14px;
  color: #5a5a5a
}

button {
  float: right;
  padding: 8px 12px;
  margin: 8px 0 0;
  font-family: 'Montserrat', sans-serif;
  border: 2px solid #78788c;
  background: 0;
  color: #5a5a6e;
  cursor: pointer;
  transition: all .3s
}

button:hover {
  background: #78788c;
  color: #fff
}

div {
  content: 'Hi';
  position: absolute;
  bottom: -15px;
  right: -20px;
  background: #50505a;
  color: #fff;
  width: 320px;
  padding: 16px 4px 16px 0;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 10px 10px 40px -14px #000
}

span {
  margin: 0 5px 0 15px
}
<meta name="viewport" content="width=device-width, initial-scale=1">


<body>
  <!-- <script>
            swal("Does'nt it looks sweet?\nYes, it do!");
        </script> -->
  <form method="POST" action="#" class="form">

    <h2>Tweetscape</h2>
    <p type="Tweet Link:"><input type="url" placeholder="Enter tweet link to reply to" name="tawai">
    </p>
    <p type="Message:"><input type="text" placeholder="Say something" name="tweey">
    </p>
    <button type="submit">Post tweet</button> {% if messages %} {% for message in messages %}
    <p>{{ message }}</p> {% endfor %} {% endif %} </form>

Upvotes: 1

Views: 42

Answers (1)

disinfor
disinfor

Reputation: 11533

Just remove the width: 340px from .form. Added media query for min-width: 650px as an example (so you can see it in the snippet preview).

body {
  background: #59ABE3;
  margin: 0
}

.form {
  height: 440px;
  background: #e6e6e6;
  border-radius: 8px;
  box-shadow: 0 0 40px -10px #000;
  margin: calc(50vh - 220px) auto;
  padding: 20px 30px;
  max-width: calc(100vw - 40px);
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
  position: relative
}

@media screen and (min-width: 650px) {
  .form {
    width: 340px;
  }
}

h2 {
  margin: 10px 0;
  padding-bottom: 10px;
  width: 180px;
  color: #78788c;
  border-bottom: 3px solid #78788c
}

input {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  background: none;
  outline: none;
  resize: none;
  border: 0;
  font-family: 'Montserrat', sans-serif;
  transition: all .3s;
  border-bottom: 2px solid #bebed2
}

input:focus {
  border-bottom: 2px solid #78788c
}

p:before {
  content: attr(type);
  display: block;
  margin: 28px 0 0;
  font-size: 14px;
  color: #5a5a5a
}

button {
  float: right;
  padding: 8px 12px;
  margin: 8px 0 0;
  font-family: 'Montserrat', sans-serif;
  border: 2px solid #78788c;
  background: 0;
  color: #5a5a6e;
  cursor: pointer;
  transition: all .3s
}

button:hover {
  background: #78788c;
  color: #fff
}

div {
  content: 'Hi';
  position: absolute;
  bottom: -15px;
  right: -20px;
  background: #50505a;
  color: #fff;
  width: 320px;
  padding: 16px 4px 16px 0;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 10px 10px 40px -14px #000
}

span {
  margin: 0 5px 0 15px
}
<meta name="viewport" content="width=device-width, initial-scale=1">


<body>
  <!-- <script>
            swal("Does'nt it looks sweet?\nYes, it do!");
        </script> -->
  <form method="POST" action="#" class="form">

    <h2>Tweetscape</h2>
    <p type="Tweet Link:"><input type="url" placeholder="Enter tweet link to reply to" name="tawai">
    </p>
    <p type="Message:"><input type="text" placeholder="Say something" name="tweey">
    </p>
    <button type="submit">Post tweet</button> {% if messages %} {% for message in messages %}
    <p>{{ message }}</p> {% endfor %} {% endif %} </form>

Upvotes: 1

Related Questions