Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

Responsive Product Card Using Flexbox

BekstersLab•40
@BekstersLab
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I had an issue creating the spacing between the sale/full prices and the cart icon/button text. I tried adding a right-margin using the following pseudo-elements:

         <div class="prices">
            <p>
              <span class="sale-price">$149.99</span>
              <span class="full-price">$169.99</span>
            </p>
          </div>
.sale-price::after {
  margin-right: 20px;
}

The only fix I could come up with was to add multiple non-breaking spaces to my html file. The pseudo-elements work fine if I add content, just not with adding margins or padding.

Googling came up with the solution to apply display:block to the parent element. I tried adding this to all classes for container elements all the way up to, but not including, main but this made no difference.

Any help on resolving this issue would be greatly appreciated as I'm not happy with using non-breaking spaces and it bothers me that I don't understand why the pseudo-elements are behaving this way.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on BekstersLab's solution.

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
  • Use cases

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