Hey there ! Would love some feedback on this task. Especially as to whether my use of sematic html was appropriate. If there is anything wrong with my code, I'd be more than happy to take on your suggestions. Thanks so much !
Elaine
@elaineleungAll comments
- @dboca93Submitted 11 months ago@elaineleungPosted 11 months ago
Hey Dilhan, excellent job here, and it makes me want to go back and clean up some of my old code for this challenge!
The semantic HTML looks pretty clean to me :) In terms of suggestions, one I could think of would probably be just to add a
header
tag even though it can be optional, but it would be nice to have since you got amain
tag with anh1
in there, and I might put thath1
underheader
instead. (By the way, what you did with theh1
was also something I did for a lot of these component challenges... I think that's a good idea too!)One other thing I saw (which was also something I did in my own solution) was putting the stats in
p
tags. If I could do that differently now, I would have the stats as anul
list instead, as that might be easier to pick out for users with a screenreader.Once again, great work!!
Marked as helpful1 - @dhan5aSubmitted almost 2 years ago
I don't think I got the font-sizes correct, compared to the design.
Also, I tried using root values for the colours, but in the end I had to use the hsl values as the values were not recognised.
Would love your feedback!
@elaineleungPosted almost 2 years agoHi Dhanya, first off, I think you did a great job putting this together! About the custom variables not working, it looks like there's a trailing curly brace in line 3 of your CSS file, and I think if you try to remove that, you'd be able to use the variables (I tried it in the browser just now using your code).
Some suggestions I have here: I'd remove the
width: 50%
from the body selector, and if you're hoping to put some space on the sides to prevent the component from touching the browser sides, instead of havingmax-width: 300px
on.card
, you can trywidth: min(90%, 300px)
. This declaration tells the browser to keep the width at 90% until it gets to 300px, at which point the width would be maintained at 300px as the max width.Lastly, about using fixed pixel values in font sizes: It's generally good practice to use relative units (such as rem), so that's something I encourage you to try as well (by default, 1 rem is 16px). One of the main reasons is because relative units allow users to have their own preferred browser/system settings and won't be locked into using fixed sizes in the code.
(Oh, and be sure to fix add alt tags in your
img
elements, otherwise these would show up in your report for sure)Hope this helps you out!
Marked as helpful1 - @DytomaSubmitted almost 2 years ago
This a solution to the frontend challenge on interactive rating component. I used Javascript on this challenge but I don't know if this is best practice so if you have time check out the repository and I would appreciate having any feedback, tip or remarks. Thanks.
@elaineleungPosted almost 2 years agoHi Dytoma, this looks like a great start, and I think your code works fine. I do suggest giving your classes and variables more meaning names, where instead of
const rating = document.querySelectorAll(".nbr");
... you can try something like this:
const ratingBtns = document.querySelectorAll(".rating"); // note that Btns stand for buttons since there is more than 1 button here!
For the
for
loop, I suggest usingclassList
instead ofclassName
so that you can easily add or remove a class instead of changing theclassName
attribute directly. I also don't thinkselected
needsquerySelectorAll
since there's only one button being selected. You can try this:for(let i = 0; i < rating.length; i++) { rating[i].addEventListener("click", function() { let selected = document.querySelector(".selected"); selected.classList.remove("selected") this.classList.add("selected"); }); }
Lastly, instead of having a default score of 1, I would just leave it empty and let the user choose. Sometimes users might accidentally click on the submit before they select the score, and you wouldn't want them to accidentally send a score of 1! Hope this helps you out a bit 🙂
1 - @trunglam7Submitted almost 2 years ago
Any ways to improve my approach to this challenge?
@elaineleungPosted almost 2 years agoHi Trung, I think this looks quite well put together! If there's one thing I'd change, I would use a class to change the style of the selected button instead of using the
:focus
pseudo class, seeing that focus is meant to used for showing which element the user had last interacted with. If you accidentally click on something else like the background or the text, the selected button would go back to its unselected color because it has lost the focus, and that would make it seem like no button got selected, even though in the background JS is still keeping track which button got selected. I would just create a new class calledselected
, style the selected button with that class, and then use JS to add/remove the class as needed. Hope this helps you out a bit!Marked as helpful2 - @Owura-56Submitted almost 2 years ago
The comment arrow was a little problem for me and this is my first time using media queries and it really gave me a headache views and suggestions are welcome
@elaineleungPosted almost 2 years agoHi Agyemang, good job putting this together! For the triangle with the
::after
pseudo element, instead of having justborder: solid transparent
, try specifying the sides, like this:.grid-item-3::after { top: 98%; right: 0; // remove left border-left: solid transparent; border-top: solid white; // rest of your code }
Also, change the border-radius in
.grid-item-3
toborder-radius: 8px 8px 0 8px;
, which should give you that sharp corner instead of a rounded one.With the media query, I'd choose a much higher breakpoint since right now when the layout changes, the sides are cut off. Also, there appears to be some overflow going on, and I think it may have to do with the large margins you're using (such as in
.grid-item-3
) to do positioning. I would actually suggest not having.grid-item-3
as a grid element but to have that as a child of.grid-item-2
instead, and I'd useposition: absolute
instead of using things likemargin-left: 21rem
, which is what I think is causing things to be pushed off to the right side of the screen.Hope this helps you out!
0 - @jodyvanhooseSubmitted almost 2 years ago
Just looking for some general feedback. Thanks!
@elaineleungPosted almost 2 years agoHi Jody, first off, great job in getting your solution to look very close to the design! 🙂 I think you did many things well; for instance, I like how readable and well-annotated your code is. There are just a few things I noticed in the area of responsive design that you can check out:
Breakpoint: The breakpoint is quite large, and you'll notice that the photo in the mobile view gets pixelated past its width of 686px, plus having the mobile view at such a wide width is not very optimal for this card component, as the photo would be gigantic while the lines of text and CTA button gets stretched. What I suggest is to use a smaller breakpoint: to find ideal point, simply see how wide the desktop view is meant to be and use that as a starting point. From what I recall, the design's desktop width should be about 600px.
Image distortion: The image at the desktop view is getting distorted, meaning that the original aspect ratio is being changed. To make sure the image doesn't get stretched or squished, add a
object-fit: cover
to the image class.Component width: Aside from changing the breakpoint, one other thing you can try is to ensure the mobile view card width doesn't get too wide. To do that, instead of just having
width: 93%
, trywidth: min(93%, 400px);
which tells the browser to keep the width at 93% if the width is smaller than 400px (you can use any value here you wish). Likewise, for the desktop view, trywidth: min(93%, 600px);
instead ofwidth: 35%
. Once you do that, you may find that thewidth
property for your desktop image doesn't have to be 25%; in fact, it can be 100% or 50% and still be the same width because you haveflex: 1
as a declaration, and you also have awidth: 50%
for your description container.Hope this can help you out!
Marked as helpful0 - @ahmad-codSubmitted almost 2 years ago
Why doesthe register btn and logo, change position if features or company dropdown is clicked?
@elaineleungPosted almost 2 years agoHey Ahmad, well done in building together this solution! To answer your question about why things shift when you click on the dropdown, it's because the dropdown has a
position: relative
. That means that when it appears, its height is part of the header height, and so everything shifts according to that height change.To fix this in the desktop view, simply change the position property in
.dropdown
toposition: absolute
instead and addposition: relative
to your.primary-navigation li
selector, so that the browser knows which parent to anchor.dropdown.
to in the positioning. You may also have to change theleft
andtop
properties as you see fit. I'd also suggest adding awidth: max-content;
to make sure the content takes the whole width and not need to be pushed to the next line. For the mobile view, be sure to keep thatposition: relative
in the.dropdown
when clicked, like how you had it.Hope this helps you out!
Marked as helpful1 - @lily-oliverSubmitted about 2 years ago
Hi, friends!
I'm very new to HTML and CSS but decided to try out Frontend Mentor. I've been following a Udemy web development course, and this is the first time I've really strayed away from it. I definitely felt the gaps in my knowledge. Until I did this project, I didn't really understand nesting in CSS. I think this has given me a better idea. Also, centering items within the body of the page is particularly hard for me. It took a lot of Googling to figure it out. Any pointers on how to remember what to do?
I'm super eager to learn more, so please let me know if you have any feedback at all!
P.S., I wasn't sure if that was a drop shadow or compression artifacts around the card... so I added a little shadow.
@elaineleungPosted about 2 years agoHi Lily, first off, welcome to Frontend Mentor, and congrats on completing your very first challenge! It's a huge step when you go from tutorials to actually writing your own code, and I must say that for your first challenge, you've done an excellent job!
About your question on centering items, it kind of depends on how you want things to look. Some people want their attribution as a footer pushed all the way to the end of the page, and some people might want it close to their component, which might be somewhere in the center. In your solution, you had your attribution within the component. Each of these cases could have slight variations in how the CSS is written, but regardless what the case is, the key thing that most people tend to forget is the height, which is very crucial because the browser needs to know how much space there is so that it knows where to place the component with even spacing around it. Even when people do remember to add the height, the mistake that most of them make is that they they use
height: 100%
orheight: 100vh
instead ofmin-height: 100vh
.In any case, for the most basic kind of centering where you want everything in the center, here's what you can do:
// centering everything in the middle using flexbox: body { min-height: 100vh; display: flex; flex-direction: column; // this is needed if you have more than one child in the body selector align-items: center; justify-content: center; } // centering everything in the middle using grid: body { min-height: 100vh; display: grid; place-content: center; }
I encourage you to play around with both flexbox and grid so that you understand how they work because I also struggled a lot in the beginning with how to use them for centering things, especially when there are other components involved, like a footer and header.
Anyway, aside from comments on centering, one suggestion I have for your solution is to add a 1rem margin around it so that for smaller browser widths, the sides of the component won't be touching the browser. I really think you did a great job on the whole, and the real challenge will come when you need to work with responsive design (as in building a mobile view and desktop view), but no worries, I think you'll be learning lots when you put your skills to the test!
Marked as helpful2 - @ArthurKingDevSubmitted about 2 years ago
Hi everyone! I finished the product preview card component challenge. kindly take a look and give me feedback if there is something I need to do better. Thanks.
@elaineleungPosted about 2 years agoHi Kingsley, good job putting this together! 😊 I got a few suggestions for you here:
-
Instead of using
background-image
for handling the switching of the desktop and mobile images, try to use thepicture
element instead since this is a product image and is thus central to the card. Thebackground-image
property is suitable for images that really are background images, usually with some text on top of the image. For the picture element, you can try something like this:<picture> <source media="(max-width: 375px)" srcset="image-mobile.png" /> <img src="image-desktop.png" alt="Glass perfume bottle placed against a leafy background" /> </picture>
-
I suggest a higher breakpoint than 375px. The 1440px desktop view and 375px mobile views are references for you to see how the component should look like that these two views, but they aren't meant to be the max width or breakpoint. As the developer, you'll have to have the judgment to see which point to use so that when the layout changes, the component can still have optimal views.
-
Right now the component isn't so responsive due to fixed widths in certain areas, and as a result, there is content that's being covered by the browser, causing overflow to happen. A big part of this could be the fact that you're using background images right now, but you can also try what I mentioned about changing the breakpoint as well.
-
To make the image width even with the text in the desktop layout, try adding
flex: 1 0 50%;
on theproduct-img
.
Hope some of this can help you out, and really great work on the whole, so keep going!
Marked as helpful0 -
- @debriksSubmitted about 2 years ago
Hi Guys! Received some very helpful feedback and refactored my first solution. I improved the HTML markup, changed some values that were still in px to relative units, removed the 'alt' attribute in the images as it was only decorative and changed the 'cursive' font property to 'sans-serif' to avoid getting 'Comic Sans'. Let me know if I missed something. Big thanks again to Lucas and Deniel!
@elaineleungPosted about 2 years agoGreat work Deborah! This looks really good, and I think the responsiveness is quite well done. I just got two suggestions:
-
At around the 660px breakpoint when the layout changes, the sides of the component are touching the sides of the browser, so I'd probably just add some spacing to keep that from happening (maybe
margin: 1rem
would be good enough!) -
Your report is giving you some issues about missing alt tags, and actually even for decorative images, you still need the alt tag in the
img
, but you can keep it empty, like this:<img scr="image.png" alt="" >
Once again, well done here, and I'm glad you got improve upon your old solution!
Marked as helpful1 -
- @ajay117Submitted about 2 years ago
Guys, I will be very grateful to have any feedback on this challenge...
@elaineleungPosted about 2 years agoHi Ajay, well done in building this component! I think there are many things you did well, including making the component responsive, having optimal views, making everything functional with the JS, and having descriptive class names. I found your code to be clean and easy to read, so great job here!
I think the only suggestion I have is that instead of using
li
for the buttons, try to use either a button or radio inputs, as this would have with accessibility since these are control elements and can be used with the tab key, whereas theli
element could not be used with a tab key. Even though you can add make them into focusable control elements, there shouldn't be a need to do that when there are more suitable elements, such asbutton
.Hope this helps and once again, great job!
Marked as helpful1 - @FrozennnSubmitted about 2 years ago
Here is my solution to this challenge.
Any feedback or suggestion is more than appreciated :)
@elaineleungPosted about 2 years agoHi Marko, I think you did well on the whole! The only three suggestions I have are as follows:
-
The ratings and the testimonials are stretching out quite a bit before the browser width reaches the breakpoint. You can either try a smaller breakpoint, or better yet, use a
max-width
for the cards and ratings. I see that you have a max-width on the ratings but it's in a percentage, which means it will still continue to stretch. What I would suggest is to use a relative unit here, like rem. For starters, trymax-width: 25rem
and then adjust accordingly. -
At desktop view, the site main heading has quite a large line height. I tried changing it via the inspector but I was not able to for some reason. In any case, it would be great if that spacing is a bit smaller!
-
Instead of using the
picture
element for the SVGs, try having them asbackground-image
instead because they are merely functioning as decor elements, and they aren't really there to enhance the site content in any meaningful way.
Hope this could help you out!
Marked as helpful1 -