Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 4 years ago

HTML, CSS, Google Fonts

Heather Smith•240
@sorengrey
A solution to the Stats preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


This is my second challenge here on Frontend Mentor!

I am looking for help with my desktop version. I can't seem to figure out why the purple overlay over the image is showing at the corners. Also, my container div won't center on the page properly. If you use Chrome Devtools to Inspect, you will see there's an invisible column or margin that pushes the div to the left. I'm not sure how to correct this, but would love suggestions.

I will be adding the README tomorrow, June 23, 2021. Thanks for taking a look!

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Lucas Estevam•210
    @tl-lucasestevam
    Posted about 4 years ago

    I took a look at your code, the first thing I noticed was the use of a tag called "row", this tag does not exist in HTML, use a div with the row class if you want to bootstrap or in the same style of code as bootstrap the same for col, etc.

    Another thing is also the use of divs around the text, use semantic tags (p, h1, h2, h3, h4, h5, h6, or span). For example your card's title:

    <h1>
    Get <strong>insights</strong> that help your business grow.
    </h1>
    

    the strong in this case is a semantic HTML tag to make part of a text highlighted, then just style it in CSS

    It's also preferable to get by class rather than id, so you won't need to repeat the CSS.

    But the main thing you should do is to think about how you will organize your card, the HTML structure, there is a container that encompasses the entire card, after that, there are two divs where each one has the width: 50%, the first one will be the texts on the second will have a background with the image (you can even use the IMG tag to make it more semantic but then you will have more problems when styling, so a simple solution is to use the background with a linear gradient to put the purple in the image)

    A simpler way to do all this is using flex-box, you can see the documentation at this link: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ or in youtube tutorials if prefer but to center the card, for example, you can do the following CSS code:

    body {
       min-height: 100vh;
       display: flex;
       justify-content: center;
       align-items: center
    }
    

    I think this is the main thing for you to improve your code, English is not my native language so if you haven't understood something feels free to ask.

    I have this problem solved if you want to take a look: https://github.com/tl-lucasestevam/frontend-mentor-card/blob/main/index.html https://github.com/tl-lucasestevam/frontend-mentor-card/blob/main/css/styles.css https://www.frontendmentor.io/solutions/html-css-and-flexbox-sY-UPQbE3

    Marked as helpful
  • Dimitrios Politis•285
    @grmajik
    Posted about 4 years ago

    If I were you, I'd start over. However, if you want to debug this, imagine this.

    Imagine that you have a box (a regular DIV), then in that box you have two more boxes.

    One box holds your image (do max-width: 100%; height: auto;) Another box holds all your text (in here, format the text however you want)

    Now, do display: flex; on the BIG BOX (the outer div). Your two inner boxes will be displayed side by side.

    Now if you do display: flex; height: 100vh align-items: center; justify-content: center; on the BODY tag, you'll get everything in the center of the page. Go from there and figure out the rest.

    Happy coding 💪

    BTW: Get rid of Bootstrap

    Marked as helpful

Join 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

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub