Форма обратной связи на конверте - PullRequest
0 голосов
/ 21 сентября 2019

У меня проблемы с контактной формой конверта.Он отлично работает на настольном компьютере, но из-за проблем он становится отзывчивым.Прямо сейчас, кажется, проблема переполнения.Я считаю, что это связано с использованием ширины и высоты в пикселях.Я пытался сделать ширину и высоту в%, а также переполнение: скрытый;но не повезло.Как сделать мой код адаптивным, чтобы он хорошо работал и на мобильных устройствах, и на планшетах?

body,
div,
h1,
h2,
form,
fieldset,
input,
textarea,
footer,
p {
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
}

.turbotobias-contact-section-wrapper {
  background-color: #ffffff;
  color: #000000;
  font-family: open sans, Arial, sans-serif;
  height: 60vh;
  display: flex;
}

.turbotobias-contact-section-wrapper p {
  font-size: 24px;
}

#wrap {
  width: 530px;
  margin: 20px auto 0;
  height: 1000px;
}

h1 {
  margin-bottom: 20px;
  text-align: center;
  font-size: 35px;
  font-family: open sans, Arial, sans-serif;
  color: white;
}

#form-wrap {
  overflow: hideen;
  height: 447px;
  position: relative;
  top: 0px;
  transition: all 1s ease-in-out 0.3s;
}

#form-wrap:before {
  content: "";
  position: absolute;
  bottom: 128px;
  left: 0px;
  background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-before.png) !important;
  width: 530px;
  height: 317px;
}

#form-wrap:after {
  content: "";
  position: absolute;
  bottom: 0px;
  left: 0;
  background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-after.png) !important;
  width: 530px;
  height: 259px;
  z-index: 999;
}

#form-wrap.hide:after,
#form-wrap.hide:before {
  display: none;
}

#form-wrap:hover {
  height: 777px;
  top: -200px;
}

form {
  background: white;
  position: relative;
  top: 200px;
  overflow: hidden;
  height: 200px;
  width: 400px;
  margin: 0px auto !important;
  padding: 20px !important;
  border: 1px solid white;
  border-right: 3px;
  transition: all 1s ease-in-out 0.3s;
}

#form-wrap:hover form {
  height: 530px;
}

label {
  margin: 11px 20px 0 0;
  font-size: 15px;
  color: gray;
  text-transform: uppercase;
}

input[type="text"],
textarea {
  font: 14px normal uppercase, arial, serif;
  color: dimgray;
  background: none;
  width: 380px;
  height: 37px;
  padding: 0px 10px;
  margin: 0 0 10px 0;
  border: 1px solid #f8f5f1;
  border-radius: 5px;
}

textarea {
  height: 80px;
  padding-top: 14px;
}

textarea:focus,
input[type="text"]:focus {
  background: white;
}

#form-wrap input[type="submit"] {
  position: relative;
  font-family: open sans, Arial, sans-serif;
  font-size: 24px;
  color: gray;
  width: 100%;
  text-align: center;
  opacity: 0;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  border: none !important;
  transition: opacity 0.7s ease-in-out 0s;
}

#form-wrap:hover input[type="submit"] {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease-in-out 1.3s;
}

.turbotobias-contact-row {
  display: flex;
  width: 80%;
  max-width: 1080px;
  margin: auto;
  padding-bottom: 50px;
  flex-direction: row;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .turbotobias-contact-row {
    padding: 30px 0;
  }
}
   <div class='turbotobias-contact-section-wrapper'>
        <div class='turbotobias-contact-row'>
            <div id="wrap">
                <br><br><br>
                <div id="form-wrap">
                    <form>
                        <p>HEJ TURBOTOBIAS,</p>
                        <label for="email">Din besked:</label>
                        <textarea name="message" id="message" value="Your message"></textarea>

                        <p>VENLIG HILSEN,</p>
                        <label for="name">Navn:</label>
                        <input type="text" name="name" value="" id="">

                        <label for="email">Email:</label>
                        <input type="text" name="email" value="" id="email">

                        <input type="submit" name="submit" value="SEND MIN BESKED TAK!">
                        </form>
                        </div>
            </div>
        </div>
    </div>

Ответы [ 2 ]

1 голос
/ 27 сентября 2019

Это из-за фиксированной ширины изображений.Я сделал несколько изменений в вашем CSS, чтобы он работал.

Вот обновленная скрипка:

body,
div,
h1,
h2,
form,
fieldset,
input,
textarea,
footer,
p {
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
}

.turbotobias-contact-section-wrapper {
  background-color: #ffffff;
  color: #000000;
  font-family: open sans, Arial, sans-serif;
  height: 60vh;
  display: flex;
}

.turbotobias-contact-section-wrapper p {
  font-size: 24px;
}

#wrap {
  width: 550px;
  margin: 20px auto 0;
  height: 1000px;
}

h1 {
  margin-bottom: 20px;
  text-align: center;
  font-size: 35px;
  font-family: open sans, Arial, sans-serif;
  color: white;
}

#form-wrap {
  overflow: hideen;
  height: 447px;
  position: relative;
  top: 0px;
  transition: all 1s ease-in-out 0.3s;
}

#form-wrap:before {
  content: "";
  position: absolute;
  bottom: 128px;
  left: 0px;
  background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-before.png) !important;
  width: 530px;
  height: 317px;
}

#form-wrap:after {
  content: "";
  position: absolute;
  bottom: 0px;
  left: 0;
  background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-after.png) !important;
  width: 530px;
  height: 259px;
  z-index: 999;
}

#form-wrap.hide:after,
#form-wrap.hide:before {
  display: none;
}

#form-wrap:hover {
  height: 777px;
  top: -200px;
}

form {
  background: white;
  position: relative;
  top: 200px;
  overflow: hidden;
  height: 100px;
  width: 400px;
  margin: 0px auto !important;
  padding: 20px !important;
  border: 1px solid white;
  border-right: 3px;
  transition: all 1s ease-in-out 0.3s;
}

#form-wrap:hover form {
  height: 530px;
}

label {
  margin: 11px 20px 0 0;
  font-size: 15px;
  color: gray;
  text-transform: uppercase;
}

input[type="text"],
textarea {
  font: 14px normal uppercase, arial, serif;
  color: dimgray;
  background: none;
  width: 380px;
  height: 37px;
  padding: 0px 10px;
  margin: 0 0 10px 0;
  border: 1px solid #f8f5f1;
  border-radius: 5px;
}

textarea {
  height: 80px;
  padding-top: 14px;
}

textarea:focus,
input[type="text"]:focus {
  background: white;
}

#form-wrap input[type="submit"] {
  position: relative;
  font-family: open sans, Arial, sans-serif;
  font-size: 24px;
  color: gray;
  width: 100%;
  text-align: center;
  opacity: 0;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  border: none !important;
  transition: opacity 0.7s ease-in-out 0s;
}

#form-wrap:hover input[type="submit"] {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease-in-out 1.3s;
}

.turbotobias-contact-row {
  display: flex;
  width: 80%;
  max-width: 1080px;
  margin: auto;
  padding-bottom: 50px;
  flex-direction: row;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .turbotobias-contact-row {
    padding: 30px 0;
    width: 100%;
  }
  #form-wrap:before,
  #form-wrap:after {
    width: 100%;
    background-size: contain!important;
    background-repeat: no-repeat!important;
  }
  #form-wrap:after {
    height: 220px;
    bottom: 30px;
  }
  #wrap {
    width: 445px;
  }
  form {
    width: 320px;
  }
}

@media (max-width: 480px) {
  #wrap {
    width: 320px;
  }
  #form-wrap:after {
    height: 240px;
  }
  form {
    height: 0;
    width: 90%;
  }
  input[type="text"],
  textarea {
    width: 100%;
  }
  .turbotobias-contact-section-wrapper p {
    font-size: 19px;
    text-align: center;
    margin-top: -20px;
    height: 60px;
  }
}
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<div class='turbotobias-contact-section-wrapper'>
  <div class='turbotobias-contact-row'>
    <div id="wrap">
      <br><br><br>
      <div id="form-wrap">
        <form>
          <p>HEJ TURBOTOBIAS,</p>
          <label for="email">Din besked:</label>
          <textarea name="message" id="message" value="Your message"></textarea>

          <p>VENLIG HILSEN,</p>
          <label for="name">Navn:</label>
          <input type="text" name="name" value="" id="">

          <label for="email">Email:</label>
          <input type="text" name="email" value="" id="email">

          <input type="submit" name="submit" value="SEND MIN BESKED TAK!">
        </form>
      </div>
    </div>
  </div>
</div>
0 голосов
/ 27 сентября 2019

@ TobiasM Вы создали очень красивую форму для связи, но для того, чтобы настроить ее в отзывчивом виде, нужно очень много усилий.

Я установил различные width некоторых элементов с разрешением 767px.

здесь под моими изменениями ..

в первую очередь я устанавливаю box-sizing на border-box

*, ::after, ::before{
  box-sizing:border-box;
}

после этого набора height, width и другие требуютсяcss для мобильного и мобильного портрета, чтобы установить все как можно лучше ..

@media (max-width: 767px){
  #form-wrap:after {
    content: "";
    background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-after.png) no-repeat center;
    height: 158px;
    background-size: 100%;
  }
  form {
      position: relative;
      top: 300px;
      height: 138px;
      width: calc(100% - 20px);
  }
  #form-wrap:before {
      content: "";
      bottom: 76px;
      background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-before.png) no-repeat center;
      width: 100%;
      height: 194px;
      background-size: 100%;
  }
  #wrap {
    width: 320px;
  }
  #form-wrap:hover {
      height: 830px;
      top: -200px;
  }
  input[type="text"], textarea{
    width:100%;
    font-size: 12px;
  }
  #form-wrap input[type="submit"]{
    font-size:18px;
  }
  .turbotobias-contact-section-wrapper p {
      font-size: 18px;
  }
  label{
        font-size: 12px;
  }
}
@media (max-width: 330px){
      form{
        height: 128px;
      }
}

здесь, в приведенной ниже скрипке вы можете проверить отзывчивость для мобильного.

body,
div,
h1,
h2,
form,
fieldset,
input,
textarea,
footer,
p {
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
}
*, ::after, ::before{
  box-sizing:border-box;
}
.turbotobias-contact-section-wrapper {
  background-color: #ffffff;
  color: #000000;
  font-family: open sans, Arial, sans-serif;
  height: 60vh;
  display: flex;
}

.turbotobias-contact-section-wrapper p {
  font-size: 24px;
}

#wrap {
  width: 530px;
  margin: 20px auto 0;
  height: 1000px;
}

h1 {
  margin-bottom: 20px;
  text-align: center;
  font-size: 35px;
  font-family: open sans, Arial, sans-serif;
  color: white;
}

#form-wrap {
  overflow: hidden;
  height: 447px;
  position: relative;
  top: 0px;
  transition: all 1s ease-in-out 0.3s;
}

#form-wrap:before {
  content: "";
  position: absolute;
  bottom: 128px;
  left: 0px;
  background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-before.png) ;
  width: 100%;
  height: 317px;
}

#form-wrap:after {
  content: "";
  position: absolute;
  bottom: 0px;
  left: 0;
  background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-after.png);
  width: 100%;
  height: 259px;
  z-index: 999;
}

#form-wrap.hide:after,
#form-wrap.hide:before {
  display: none;
}

#form-wrap:hover {
  height: 777px;
  top: -200px;
}

form {
  background: white;
  position: relative;
  top: 200px;
  overflow: hidden;
  height: 200px;
  width: 100%;
  margin: 0px auto !important;
  padding: 20px !important;
  border: 1px solid white;
  border-right: 3px;
  transition: all 1s ease-in-out 0.3s;
}

label {
  margin: 11px 20px 0 0;
  font-size: 15px;
  color: gray;
  text-transform: uppercase;
}

input[type="text"],
textarea {
  font: 14px normal uppercase, arial, serif;
  color: dimgray;
  background: none;
  width: 380px;
  height: 37px;
  padding: 0px 10px;
  margin: 0 0 10px 0;
  border: 1px solid #f8f5f1;
  border-radius: 5px;
}

textarea {
  height: 80px;
  padding-top: 14px;
}

textarea:focus,
input[type="text"]:focus {
  background: white;
}

#form-wrap input[type="submit"] {
  position: relative;
  font-family: open sans, Arial, sans-serif;
  font-size: 24px;
  color: gray;
  width: 100%;
  text-align: center;
  opacity: 0;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  border: none !important;
  transition: opacity 0.7s ease-in-out 0s;
}

#form-wrap:hover input[type="submit"] {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease-in-out 1.3s;
}

.turbotobias-contact-row {
  display: flex;
  width: 80%;
  max-width: 1080px;
  margin: auto;
  padding-bottom: 50px;
  flex-direction: row;
  flex-wrap: wrap;
}
#form-wrap:hover form {
    height: 515px;
}
@media (max-width: 980px) {
  .turbotobias-contact-row {
    padding: 30px 0;
  }
}
@media (max-width: 767px){
  #form-wrap:after {
    content: "";
    background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-after.png) no-repeat center;
    height: 158px;
    background-size: 100%;
  }
  form {
      position: relative;
      top: 300px;
      height: 138px;
      width: calc(100% - 20px);
  }
  #form-wrap:before {
      content: "";
      bottom: 76px;
      background: url(https://www.onlinefox.dk/wp-content/uploads/2019/09/brev-before.png) no-repeat center;
      width: 100%;
      height: 194px;
      background-size: 100%;
  }
  #wrap {
    width: 320px;
  }
  #form-wrap:hover {
      height: 830px;
      top: -200px;
  }
  input[type="text"], textarea{
    width:100%;
    font-size: 12px;
  }
  #form-wrap input[type="submit"]{
    font-size:18px;
  }
  .turbotobias-contact-section-wrapper p {
      font-size: 18px;
  }
  label{
        font-size: 12px;
  }
}
@media (max-width: 330px){
      form{
        height: 128px;
      }
}
<div class='turbotobias-contact-section-wrapper'>
        <div class='turbotobias-contact-row'>
            <div id="wrap">
                <br><br><br>
                <div id="form-wrap">
                    <form>
                        <p>HEJ TURBOTOBIAS,</p>
                        <label for="email">Din besked:</label>
                        <textarea name="message" id="message" value="Your message"></textarea>

                        <p>VENLIG HILSEN,</p>
                        <label for="name">Navn:</label>
                        <input type="text" name="name" value="" id="">

                        <label for="email">Email:</label>
                        <input type="text" name="email" value="" id="email">

                        <input type="submit" name="submit" value="SEND MIN BESKED TAK!">
                        </form>
                        </div>
            </div>
        </div>
    </div>
...