Pod Request Access Landing Page with Flexbox and JavaScript
Design comparison
Solution retrospective
This challenge was tough getting the layout to the designs! I do have some questions though.
-
Does
position:absolute
cause elements to move around when the viewport is resized? -
Is there an easy way to change the color of the svgs?
-
What stumped me the most with the JavaScript, how to get the boolean value from the Regex to compare it to the email
<input>
. What ended up working was passing in the variablesemailValue
instead ofemail
into the Regex, which I don't fully understand, It seems that they are both strings? If you understand why, let me know!
Community feedback
- @dmitrymitenkoffPosted about 3 years ago
Great job, Marcus. The landing page looks great and is responsive to the changes in the viewport dimensions.
With regard to your question about
position: absolute
, there could be a number of reasons for the absolutely positioned elements to move around (I assume you ask about these in particular). What helps me is to think about positioning elements in terms of containing blocks - these are the boxes absolutely positioned elements are relative to. One thing to remember is that these containing blocks are not necessarily direct parents of absolutely positioned elements. These are the elements whose position is set toposition: relative
. So to answer your question: try finding the relatively positioned box in your code, and then, by using thetop
,left
,bottom
,right
properties, you can "glue" the absolutely positioned element to wherever on the page you want, relative to the parent element, which is pretty much what you've done in your media query onmain
!I often find myself fighting with SVGs! If I know that I may want to change the colour of an SVG element (eg, on hover), I normally include an inline version of my SVG directly into my HTML instead of using an
<img>
tag. This way, I can change the SVG property calledfill
in CSS (it's like a color property), you can find more examples here.With your JS email validation function, you could try redesigning it a little bit, like so:
function checkEmailValue(email) { const result = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (result.test(email.value.trim())) { // returns true if email is valid // show success, eg green border } else { // validation failed - returns false // do something, eg red border and error message }
You can then call this function directly in your event listener, like so:
form.addEventListener('submit', function(event) { event.preventDefault(); checkEmailValue(email); });
I recently learnt about a Constraint Validation API (built in JS) that works beautifully with HTML5. Here's more information about this method, if you decide to try it in one of your future projects:
Hope this is helpful. Keep up the great work, Marcus!
Marked as helpful0@marcus-hugoPosted about 3 years ago@dmitrymitenkoff Thanks so much for the great feedback!
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord