Responsive Web Design Projects - Build a Survey Form
A Pen by Valentin TT on CodePen.
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> | |
<!-- | |
Hello Camper! | |
For now, the test suite only works in Chrome! Please read the README below in the JS Editor before beginning. Feel free to delete this message once you have read it. Good luck and Happy Coding! | |
- The freeCodeCamp Team | |
--> | |
<header class="center-h"> | |
<h1 id="title">Bees monitoring</h1> | |
</header> | |
<main> | |
<p class="center-h" id="description">This survey is <em>only</em> for beekepers.</p> | |
<form id="survey-form" action=""> | |
<label for="name" id="name-label">Name:</label> | |
<input type="text" id="name" placeholder="Full name" required> | |
<label for="email" id="email-label">eMail:</label> | |
<input type="email" name="email" id="email" placeholder="The one you use the most" required> | |
<label for="dropdown" id="dropdown-label"> | |
What is beekeping for you?</label> | |
<select name="dropdown" id="dropdown"> | |
<option value="full-time">Full-time job</option> | |
<option value="part-time">Part-time job</option> | |
<option value="hobby">Just a hobby</option> | |
</select> | |
<label for="number" id="number-label">How many hives do you have?</label> | |
<!--//TODO: pensar en eliminar el placeholder--> | |
<input type="number" name="number-hives" id="number" min="1" max="2000000" placeholder="0" required> | |
<fieldset> | |
<legend>How often do you visit your hives?</legend> | |
<div class="mg-left"> | |
<label for="every-week"> | |
<input type="radio" name="times" id="every-week" value="every-week"> Every week</label> | |
<label for="every-two-weeks"> | |
<input type="radio" name="times" id="every-two-weeks" value="every-two-week"> Every two weeks</label> | |
<label for="every-month"> | |
<input type="radio" name="times" id="every-month" value="every-month"> Every month</label> | |
</div> | |
</fieldset> | |
<fieldset> | |
<legend>Do your hives get sick?</legend> | |
<div class="mg-left"> | |
<label for="yes"> | |
<input type="radio" name="rb-get-sick" id="yes" value="yes"> Yes | |
</label> | |
<label for="no"> | |
<input type="radio" name="rb-get-sick" id="no" value="no"> No | |
</label> | |
</div> | |
</fieldset> | |
<fieldset> | |
<legend>What products do you produce?</legend> | |
<div class="mg-left"> | |
<label for="honey"> | |
<input type="checkbox" name="cb-product" id="honey" value="honey"> Honey | |
</label> | |
<label for="pollen"> | |
<input type="checkbox" name="cb-product" id="pollen" value="pollen"> Pollen | |
</label> | |
<label for="royal-jelly"> | |
<input type="checkbox" name="cb-product" id="royal-jelly" value="royal-jelly"> Royal Jelly | |
</label> | |
<label for="wax"> | |
<input type="checkbox" name="cb-product" id="wax" value="wax"> Wax | |
</label> | |
<div class="cb-product-other"> | |
<label for="other"> | |
<input type="checkbox" name="cb-product" id="other" value="other"> Other | |
<textarea name="other-product" id="other-product" cols="30" rows="1" placeholder="What is it?"></textarea> | |
</label> | |
</div> | |
</div> | |
</fieldset> | |
<div class="align-left-h"> | |
<button id="submit">Submit</button> | |
</div> | |
</form> | |
</main> | |
<footer class="center-h"> | |
<p>Coded by <a href="https://github.com/ValentinTapiaTorti" target="_blank"> Valentin TT</a>.</p> | |
</footer> |
// !! IMPORTANT README: | |
// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place. | |
/*********** | |
INSTRUCTIONS: | |
- Select the project you would | |
like to complete from the dropdown | |
menu. | |
- Click the "RUN TESTS" button to | |
run the tests against the blank | |
pen. | |
- Click the "TESTS" button to see | |
the individual test cases. | |
(should all be failing at first) | |
- Start coding! As you fulfill each | |
test case, you will see them go | |
from red to green. | |
- As you start to build out your | |
project, when tests are failing, | |
you should get helpful errors | |
along the way! | |
************/ | |
// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example! | |
// Once you have read the above messages, you can delete all comments. |
:root { | |
--bg-body: #9B4DCA; | |
--bg-footer: #fff; | |
--bg-main: #fff; | |
--header-color: #fff; | |
} | |
body { | |
font-family: 'Roboto Slab', serif; | |
background: var(--bg-body, white); | |
display: grid; | |
grid-template-rows: auto 1fr auto; | |
grid-template-columns: 20% 1fr 20%; | |
grid-template-areas: "header header header" | |
". survey ." | |
"footer footer footer"; | |
} | |
.center-h { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.mg-left { | |
margin-left: 15px; | |
} | |
.align-left-h { | |
display: flex; | |
align-items: center; | |
justify-content: flex-end; | |
} | |
header { | |
grid-area: header; | |
padding: 2rem 0; | |
} | |
header h1 { | |
margin: 0; | |
color: var(--header-color, white); | |
} | |
footer { | |
grid-area: footer; | |
background: var(--bg-footer, white); | |
margin: 0; | |
margin-top: 2rem; | |
} | |
footer>p { | |
margin: 1rem 0; | |
} | |
main { | |
grid-area: survey; | |
background: var(--bg-main, white); | |
padding: 1em 2em; | |
border-radius: 10px; | |
} | |
input[type=number] { | |
text-align: right; | |
} | |
.cb-product-other>label>input[type=checkbox]:checked+textarea { | |
display: inline-block; | |
visibility: visible; | |
} | |
.cb-product-other>label>input[type=checkbox]:not(:checked)+textarea { | |
display: none; | |
visibility: hidden; | |
} | |
@media (max-width: 40.0rem) { | |
body { | |
grid-template-areas: "header header header" "survey survey survey" "footer footer footer"; | |
} | |
} | |
@media (max-width: 48.0rem) { | |
body { | |
grid-template-columns: 10% 1fr 10%; | |
} | |
} |
Responsive Web Design Projects - Build a Survey Form
A Pen by Valentin TT on CodePen.