Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

Responsive Website - using html, css and some bootstrap only

bootstrap
Raz Israeli•50
@PishoTo
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 have a lot of trouble making the website responsive. I have created another website while following the instructions of the course instructor, and it was a lot easier than doing things myself.

Eventually, the website I was able to build (and I took the simplest challenge here) is not really responsive...

Would love to have some comments or ideas how to improve the way I code to make this website (and my next ones) responsive without spending hours on it :)

Thanks!

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Elaine•11,360
    @elaineleung
    Posted almost 3 years ago

    Hi Raz, well done completing your first project by yourself, and welcome to Frontend Mentor! I'll try to give you some ideas here on responsiveness that might help you.

    1. First off, I can only see your desktop image and not the mobile version. While there are many ways to switch between views, one easy way is to use the img tag with srcset. This allows you to put more than one image inside the img with their widths in w; you'll have to look up the widths of the images you use, but here I've provided the ones in this challenge for you. In this way, the browser can choose which one to use at the breakpoint you specify:

      <img alt="perfume bottle" 
          srcset="images/image-product-desktop.jpg 600w, images/image- product-mobile.jpg 686w"        
          sizes="(min-width: 995px) 600px, 686px" 
          src="images/image-product-mobile.jpg">
      

      You'd also want to add object-fit:cover to your image and give it a height:100% at desktop view so that it can stretch and match the text container.

    2. Instead of using percentages for padding, try to use rem units, where 1rem is 16px. It's really just a lot easier this way (at least for me when I started using rem units), and you'd find that a lot of the padding and margins are a full round rem (e.g., 1rem, 2rem). For instance, instead of the padding: 5% 18%; in the product container, I'd use padding: 2rem instead to give the container a 2rem padding all around.

    3. I can see that something funny is happening below the 600px breakpoint. The reason for that is you're using flex-wrap with flex-direction: row (which is a default when you add display:flex even when you don't specify the flex direction), and instead of having 1 column, the text just "wraps" over to have a row of 2 columns. What I'd do is, in the product container, I'd add flex-direction: column and give it a max-width: 450px with margin-inline: auto to keep things centered. Then at your breakpoint, in the media query I'd change the flex-direction to row and change max-width to 600px in the product container; at that point the columns might be even since I see you got flex on them already. For more on responsive properties, check out this article on web.dev.

    I think that's all in terms of suggestions because this was a bit tough to troubleshoot due to all the Bootstrap classes. If you're kind of starting out, I actually suggest not using any systems (e.g., Bootstrap, Tailwind); I think you'd benefit a lot from just writing pure CSS so that you understand what each line is doing first, and I suggest experimenting a lot with this. One thing I like doing for these small components is, I would bring the code over to CodePen and just try out different things. It really helps to get the fundamentals right before bringing in a system.

    Hope some of this can help you out!

    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
Frontend Mentor logo

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 1st-party linked stylesheets, and styles within <style> tags.

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.

Oops! 😬

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

Log in with GitHub