Submitted
Don't have big difficulty in this challenge but I am not sure if there are cleaner and easier way to write the code. Also, I am not sure if the class naming of the HTML elements are clear enough.
Please advise and thanks :)
@aaronli722
Submitted
Don't have big difficulty in this challenge but I am not sure if there are cleaner and easier way to write the code. Also, I am not sure if the class naming of the HTML elements are clear enough.
Please advise and thanks :)
Submitted
When to use class and when to use id?
Is it fine to take <main> as the card container class?
Submitted
I come up with 2 questions in the challenge:
How to get a better measurement of size, dimension of an image
Have no idea how to style the number points of a <ol>
Also, for the table in the Nutritions section, I just adjusted the width of the first column to adjust of position of the text in the second column. It works but I am not sure if it is a good way to do it.
And I feel my code is redundant and can be cleaner :(
Submitted
After the project, I have two questions:
How to vertically center a span element?
Is it possible to set the height of a div same as the background image? (which mean can fully show the background image with correct scale)
Submitted
I got some questions when doing the challenge:
Is it a good way to use <main> as the background element? My purpose is to apply CCS flex so as to center the card.
Flex gap
Does flex-gap exist? I found the property on the web but nothing happen when I applied it to my code and finally, I have to use margin.
when I added svg (the eth icon and clock icon) to my codes, I found it is at the top-left of the box. I used flex align-items to center them. But is there another way to verically center svg?
to apply the hover effect of the main image, I added a div with overlay color. But is there any way that I no need to add a div but just do some css rules to the image?
There is a 1px gap at the bottom and I have to set the height to 99% to fix it.
Is it a good way to use <main> as the background element? My purpose is to apply CCS flex so as to center the card.
Flex gap
Does flex-gap exist? I found the property on the web but nothing happen when I applied it to my code and finally, I have to use margin.
when I added svg (the eth icon and clock icon) to my codes, I found it is at the top-left of the box. I used flex align-items to center them. But is there another way to verically center svg?
to apply the hover effect of the main image, I added a div with overlay color. But is there any way that I no need to add a div but just do some css rules to the image?
There is a 1px gap at the bottom and I have to set the height to 99% to fix it.
Submitted
Is there a common practice of the css properties order? for example, display comes first, then width/height, and then margin/padding, etc?
When to use class, when to use id?
In my concept, id is use when the element is unique, for example #card in this challenge. But when I studied the html code of other pages, I found that they may also use class to describe unique element. So when to use class, when to use id?
Submitted
I come up with a question about body height when working on desktop and mobile view.
In Desktop view, in order to vertically center the Card, I set the body to flexbox and give a height of 100vh to it so the property align-items can take effect.
But when working on the mobile view, as the Card becomes so long that it exceeds the screen height, I have to change the body height to auto.
So, is it possible to give a setting to body height so it can work well in both desktop and mobile view (and exceed screen height)?
Submitted
I come up with a lot of questions in this challenge:
@meida is used for CSS in different screen size. Is there any industry standard of the @media code structure? For example:
.div1 {}
@media {
.div1 {}
}
.div2 {}
@media {
.div2 {}
}
and
.div1 {}
.div2 {}
@media {
.div1 {}
.div2 {}
}
Which one is preferred?
In the challenge, initially I used <img> for the card image but then I found that I didn't know how to set the div box responsively same height as the image inside the div box. Finally I used background image instead.
Can it be possible to set the div box same height as the image when <img> is used?
I used margin to set the gap space between flexbox (the Stat Section). Is there any property instead of margin that can set it?
Is it common to give an id to a div box? Or it is more common to use class?
As you know, the preview from Frontend Mentor challenge is jpeg image. When I am dealing with the size and value (e.g. padding, margin, font size,color), I have to keep testing by my eyes. Is there any tricks or tools so that I can easily get the value?
Submitted
I am wondering if there is useful and free color picker, which does not need to upload an image to the picker?
Submitted
In this challenge, I learned:
The most challenging part is the Card Image with a view-icon with color ovarlay when hovering. In the first try, I divided it into three component: a div box, an image and a svg icon, but then I found it difficult to correctly center the icon on the image.
After studying different resources on the web, I simplified it: a div box with background-image and an svg icon. To easily center the svg icon on the image, I set the position of the div box to relative and the svg icon to absolute so the svg icon is positioned relative to its parent: the div box.
parent-div { position: relative; } child svg { position: absolute; }
The Card Image acted as the background image of the div box and so the div box needed to be responsive square to fit the image. I learned the use of padding-top to make it responsive square:
image-box { width: 100%; padding-top: 100%; }
As the svg icon was absolute positioned, it was not affected by the padding and can be easily centered:
svg-icon { left: 50%; top: 50%; transform: translate(-50%, -50%); }
Final Challenge was overlaying color on background image when hovering. After research, I learned that it can be done by linear-gradient with two same color-stop, which means no graident at all:
image-box:hover { background: linear-gradient(color1, color1), backgraound-image; }
All DONE!
I am new to HTML and CSS. I started learning from freecodecamp and w3school few months ago. I am not sure if the above solution is the best solution and it would be great if you may have a better suggestion.
Submitted