responsive form html css template

Solutions on MaxInterview for responsive form html css template by the best coders in the world

showing results for - "responsive form html css template"
Randy
24 Jun 2020
1<!DOCTYPE html>
2<html>
3<head>
4<meta name="viewport" content="width=device-width, initial-scale=1">
5<style>
6* {
7  box-sizing: border-box;
8}
9
10input[type=text], select, textarea {
11  width: 100%;
12  padding: 12px;
13  border: 1px solid #ccc;
14  border-radius: 4px;
15  resize: vertical;
16}
17
18label {
19  padding: 12px 12px 12px 0;
20  display: inline-block;
21}
22
23input[type=submit] {
24  background-color: #04AA6D;
25  color: white;
26  padding: 12px 20px;
27  border: none;
28  border-radius: 4px;
29  cursor: pointer;
30  float: right;
31}
32
33input[type=submit]:hover {
34  background-color: #45a049;
35}
36
37.container {
38  border-radius: 5px;
39  background-color: #f2f2f2;
40  padding: 20px;
41}
42
43.col-25 {
44  float: left;
45  width: 25%;
46  margin-top: 6px;
47}
48
49.col-75 {
50  float: left;
51  width: 75%;
52  margin-top: 6px;
53}
54
55/* Clear floats after the columns */
56.row:after {
57  content: "";
58  display: table;
59  clear: both;
60}
61
62/* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
63@media screen and (max-width: 600px) {
64  .col-25, .col-75, input[type=submit] {
65    width: 100%;
66    margin-top: 0;
67  }
68}
69</style>
70</head>
71<body>
72
73<h2>Responsive Form</h2>
74<p>Resize the browser window to see the effect. When the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other.</p>
75
76<div class="container">
77  <form action="/action_page.php">
78    <div class="row">
79      <div class="col-25">
80        <label for="fname">First Name</label>
81      </div>
82      <div class="col-75">
83        <input type="text" id="fname" name="firstname" placeholder="Your name..">
84      </div>
85    </div>
86    <div class="row">
87      <div class="col-25">
88        <label for="lname">Last Name</label>
89      </div>
90      <div class="col-75">
91        <input type="text" id="lname" name="lastname" placeholder="Your last name..">
92      </div>
93    </div>
94    <div class="row">
95      <div class="col-25">
96        <label for="country">Country</label>
97      </div>
98      <div class="col-75">
99        <select id="country" name="country">
100          <option value="australia">Australia</option>
101          <option value="canada">Canada</option>
102          <option value="usa">USA</option>
103        </select>
104      </div>
105    </div>
106    <div class="row">
107      <div class="col-25">
108        <label for="subject">Subject</label>
109      </div>
110      <div class="col-75">
111        <textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>
112      </div>
113    </div>
114    <div class="row">
115      <input type="submit" value="Submit">
116    </div>
117  </form>
118</div>
119
120</body>
121</html>
122