@huyphan2210
Posted
Hi, @DAJ350
I checked out your solution and have a few suggestions:
- You’re trying to center the
card
by usingmargin: 230.5px auto
, but this isn’t the best approach. Different viewports (the visible area of a web page on a user’s screen) have varying sizes, and hardcoding230.5px
won’t adapt to those differences. There are more flexible methods available, which I’ll explain below. For now, I’d recommend removing thatmargin
. - Once you’ve removed the margin, you can center both the
card
and theattribution
by using Flexbox. While there are multiple ways to achieve this, here’s a simple example using Flexbox on thebody
:
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
/* your styles below */
}
This will ensure everything is neatly centered across different viewport sizes.
- You should remove
width: 100%
from both thehtml
andbody
elements, as they are block-level elements by default, which means they naturally take up the full width of their parent container. Additionally, removeheight: 100%
from both thehtml
andbody
and instead applymin-height: 100vh
to thebody
. This ensures that thebody
always covers at least the full height of the viewport, allowing for better vertical responsiveness without restricting the content height. - Regarding your question about semantic HTML elements, your current markup is missing
<header>
,<main>
, and<footer>
. In your case, thecard
can be a <main> element, and theattribution
can be a <footer> for clearer structure and better accessibility.
Hope this helps!
Marked as helpful