Hello everyone,
I am trying to build the survey form project. It is supposed to be more or less a copy of the survey form we built in the course but with different colors. However, to my surprise, I found that with my CSS the survey form is not responsive if I change screen width. If I copy and paste the CSS from the course, the survey form becomes responsive even though I copied all the most important properties. It seems only the colors are different. Can anybody tell me what I’m doing wrong? Thank you.
My HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Registration Form</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1 id="title">Registration Form</h1>
<p id="description">Please submit your information</p>
<form id="survey-form" method="post">
<fieldset>
<label id="name-label">Enter your name: <input id="name" type="text" placeholder="John Doe" value="" required></label>
<label id="email-label">Enter your email: <input id="email" type="email" placeholder="john.doe@gmail.com" value="" required></label>
<label id="number-label">Enter your age: <input id="number" type="number" min="18" max="120" placeholder="21" value="" required></label>
</fieldset>
<fieldset>
<legend>Account type (required)</legend>
<label for="personal-account"><input type="radio" id="personal-account" name="account" value="personal" class="inline" checked>Personal account</label>
<label for="business-account"><input type="radio" id="business-account" name="account" value="business" class="inline">Business account</label>
</fieldset>
<fieldset>
<legend>Membership type (required)</legend>
<label for="basic-membership"><input type="radio" id="basic-membership" name="membership" value="basic" class="inline" checked>Basic membership</label>
<label for="premium-membership"><input type="radio" id="premium-membership" name="membership" value="premium" class="inline">Premium membership</label>
</fieldset>
<fieldset>
<label for="bio">Provide a bio:<textarea id="bio" name="bio" rows="3" cols="30" placeholder="I'm a professional developer..."></textarea></label>
</fieldset>
<fieldset>
<label for="dropdown">How did you hear about us?<select id="dropdown" name="referrer">
<option value="">(Select one)</option>
<option value="Google">Google ad</option>
<option value="YouTube">YouTube ad</option>
<option value="Other">Other</option>
</label>
</select>
</fieldset>
<label><input type="checkbox" value="mailing-list" class="inline">I agree to receive email notifications</label>
<label><input type="checkbox" value="mailing-list" class="inline">I accept the <a href="freecodecamp.org">terms and conditions</a></label>
<button type="submit" id="submit">Submit</button>
</form>
</body>
</html>
My CSS (not responsive)
body {
width: 100%;
height: 100vh;
margin: 0;
background-color: #5D8736;
color: #F5F5F5;
font-size: 16px;
font-family: serif;
}
h1, p {
text-align: center;
margin: 1rem auto;
}
form {
width: 60vh;
min-width: 300px;
max-width: 500px;
padding-bottom: 2em;
margin: 0 auto;
}
fieldset {
border: none;
}
button[type="submit"] {
display: block;
width: 60%;
margin: 1em auto;
height: 2em;
font-size: 1.1rem;
background-color: white;
border-color: white;
min-width: 300px;
}
.inline {
width: unset;
vertical-align: middle;
margin: 0 0.5em 0 0;
}
label {
display: block;
margin: 0.5rem 0;
}
input,
textarea,
select {
margin: 10px 0 0 0;
width: 100%;
min-height: 2em;
}
CSS from the course (responsive)
body {
width: 100%;
height: 100vh;
margin: 0;
background-color: #1b1b32;
color: #f5f6f7;
font-family: Tahoma;
font-size: 16px;
}
h1, p {
margin: 1em auto;
text-align: center;
}
form {
width: 60vw;
max-width: 500px;
min-width: 300px;
margin: 0 auto;
padding-bottom: 2em;
}
fieldset {
border: none;
padding: 2rem 0;
border-bottom: 3px solid #3b3b4f;
}
fieldset:last-of-type {
border-bottom: none;
}
label {
display: block;
margin: 0.5rem 0;
}
input,
textarea,
select {
margin: 10px 0 0 0;
width: 100%;
min-height: 2em;
}
input, textarea {
background-color: #0a0a23;
border: 1px solid #0a0a23;
color: #ffffff;
}
.inline {
width: unset;
margin: 0 0.5em 0 0;
vertical-align: middle;
}
input[type="submit"] {
display: block;
width: 60%;
margin: 1em auto;
height: 2em;
font-size: 1.1rem;
background-color: #3b3b4f;
border-color: white;
min-width: 300px;
}
input[type="file"] {
padding: 1px 2px;
}