Probably I'm still a newbie but I've tried to made a "junior" challenge cause I feel that I need to improve my Javascript most. From the community I would like to know how I should use position absolute in a better way in order to be more responsive(if I could use different and most useful units etc.). About JavaScript of course I'd like to refactoring the code, I know that is confusing. I wasn't able to add a class on the input to show a red border. About CSS, I wasn't able to make a linear gradient border when on focus. All the feedback Are accepted and I will be grateful to everyone!
Mark Gardner
@mark-gardner74All comments
- @lmacandaSubmitted about 2 years ago@mark-gardner74Posted about 2 years ago
Hi,
This is very close to being spot on. I often find absolute positioning a little clumsy and not very responsive... but I still use it (I have been searching for an alternative). With this challenge, I set the width of the images (using rem as a unit) and placed them using the breakpoints to fix their position (absolute within the container). The contents such as names and numbers could then be placed in the knowledge that they wouldn't wrap or move around (using flexbox to space them nicely).
With regards to the JavaScript, if it works then all good. As you go along you will find your code improves and you develop a style. The important thing is to understand what you have written and equally as important is that when you pick it up 3 months later you still understand it. It is easy to be clever with code, sometimes too clever for your future self :-). Your code is solid, well-spaced and readable. I would look at whether a variable I refer to once needs to be a variable and not just use the ID. I would also look at some of the validations, note that these can be done in HTML with a CSS pseudo-class of :invalid / :valid to format things. Common pieces of code can be combined and variables passed in. Just look for repeating code, this will come with time.
On the whole, so close, good work and best of luck for more of these challenges.
Marked as helpful0 - @SantiagoLaraESubmitted about 2 years ago
Hi there ✌️
Feedback welcome
@mark-gardner74Posted about 2 years agoHi, this is very good. The cards sliding in is a nice touch.
A couple of thoughts:
-
Your validation messages appear a little too soon. Wait until you tab out, or go to save and then display them and re-focus on the field if necessary;
-
It was difficult to know when I was getting close to 16 characters with the card number, display it live on the front of the card as you type;
-
Leave a little bit more room for the validation messages, the screen jumps a little when they appear.
Aside from these, really good work. Best of luck with the next project.
Marked as helpful0 -
- @HameezAqeelSubmitted about 2 years ago
Is there any way that I can make it more responsive using more of flexbox and less of media queries? Any kind of help or tip might be useful for a beginner like me.
@mark-gardner74Posted about 2 years agoHi,
When it comes to media queries you can have examples like:
:root { --background-color: #F00; }
.class { display: flex; flex-direction: column; height: 40em; justify-content: space around; color: white; background-color: var( --background-color ); }
@media screen and ( min-width: 768 ) {
:root { --background-color: #00F; }
.class { flex-direction: row; height: 20em; } }
Now above flex-direction changes to flex-direction: row at 768px. You will not need anything at 1024px unless you have designs on changing the direction again. The background colour changes because of the variable --background-color
You still have the media queries but change what you need to change. Use classes as far as possible. An ID is for something absolutely specific. Classes can be split up to perform fewer operations. You then have more classes, but you have more opportunities to mix and match which leads to smaller CSS files. Take a look at the principles behind Tailwind and Bootstrap.
With regards to moving to a framework. No, not yet. Whilst Frameworks are a desirable part of future employment, vanilla JS is a big part of most of them. You cannot get by in React without it. Get the know the DOM well, and how to manipulate arrays and objects. Keep going through these projects, then revisit your code in 6 months' time. You will note two things, 1: your code now whilst good is probably doing more than it should do; and 2: You will be nothing but heartened with your progress. I have been coding for a while, constant improvement is key and keeps you going.
All the best.
Marked as helpful0 - @HameezAqeelSubmitted about 2 years ago
Is there any way that I can make it more responsive using more of flexbox and less of media queries? Any kind of help or tip might be useful for a beginner like me.
@mark-gardner74Posted about 2 years agoHi,
You can make it more responsive using flexbox, easy to swap between flex-direction to make things easier to reuse. Your code is solid, very solid for a beginner in JS, must be some other programming in the past.
One tip and it is really the one that I swear by. Mobile-first. You define everything to work on mobile. Even to the extent of trying a fixed screen width of 375px for the first attempt. Design and code the mobile version and then add breakpoints (media queries) for 768px and 1024px (possibly 1440px). When you design mobile-first you will only ever be changing the bits that need changing not scaling down to a lesser screen size.
Secondly, when you design mobile-first you can see which elements of code you can group together in flexbox/grid for when you scale up. In this example the card details / main section start in mobile as flex-direction: column and then switch to row. Once you have defined something, you only need to change the bits you want to override.
Great attempt and good luck with the next one.
Marked as helpful1 - @lMahesvaraSubmitted about 2 years ago
What's the best way to make responsive design?
@mark-gardner74Posted about 2 years agoHi,
Nice work here! You ask about responsive design.
Mobile first: Now I am most certainly not the best at CSS but helpful to me is starting with mobile, your media queries start with a min-width when you get to tablet, and then desktop. You will only then change the bits that need to change having defined the bulk for mobile. An example would be having a column design for mobile (flex - column) which may change to flex - row when the screen gets bigger. Starting with desktop and then adjusting to mobile is more difficult to control;
Flexbox / Grid - all round the easiest way to make your content behave. If you use grid and need to change things around a little it is so much easier;
Use containers to wrap elements. You can control the container which will in turn constrain the elements within;
Try and stick with one unit of measurement as far as possible. em/rem dependent on what you are dealing with (rem for font, em for width/padding). Possibly %s but ems to me are the go-to.
Nice work and good luck with the next project.
Marked as helpful1 - @D4R0MSubmitted about 2 years ago@mark-gardner74Posted about 2 years ago
Nice one. Can't view the code, couple of very small issues but on the whole very good.
The image probably needs truncating on the view of the image top right. Use overflow: hidden on the container. Then have position: relative on the parent of the image, position: absolute on the image and then use top and right to position the image so that it is positioned correctly and overlaps the header section.
Aside from that the spacing underneath the main header needs increasing to probably 1.5 - 2 rem.
Congrats!
Marked as helpful1 - @DavidDelannoyDeveloppementSubmitted about 2 years ago
Your comments are welcome !
@mark-gardner74Posted about 2 years agoNice, two tiny observations. The 2 column layout has almost no gap between verticals. One way I saw around this was to have two boxes for each element, with the outer box being 100% - 50% - 33% of width dependent on mobile - tablet - desktop. Within the box, you have the content with padding so that you can create a gap inside the box and maintain space. It also helps when you use flex-wrap to keep the columns in the correct configuration. gap-row may also be handy to give a slightly different gap between the vertical and horizontal boxes.
The second, truly tiny thing is that the first box with the text "Check out..." drops slightly lower than the others in the two-column layout.
Nice though. All the best for the next project!
Marked as helpful0