Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Component with HTML, CSS e (a bit of) Javascript

Thiago Adomaitis• 195

@tadomaitis

Desktop design screenshot for the Article preview component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


How did you guys manage to make the open-on-click share bar? And how can one do that triangle tip on the bottom (web layout)?

Tips for better practices would be great, also.

Community feedback

Account Deleted

I think you forget to add background-repeat: no-repeat to .main-image selector. If U try to open your element on Galaxy Fold (From Chrome Developer Tools) you can see your background image start to repeating.

Also in my opinion if U can make something with Pure CSS don't this with JavaScript :)

Happy Coding :)

2

Thiago Adomaitis• 195

@tadomaitis

Posted

@cattofiq yeah, I did. I'll fix it and try in every device.

I didn't know I could do with Pure CSS. I'm not a fan of using needless JavaScript.

Thank you for your feedback.

0

Account Deleted

Yeah you can make many thing with Pure CSS and this is better for performance :)

0
Connor Z• 5,115

@zuolizhu

Posted

open-on-click:

I used the JavaScript to control it, to break it down:

  1. You need an event listener to that share button, when it clicked, change the class list of the tooltip.

  2. Depends on your favor, I like to add "active" class to anything where I want to control display or not. In this case, default tooltip has nothing but only display:none; to it. When the "active" class applied, then I add all the additional css to it.

  3. In css, it would like something below:

.tooltip { display: none; }

.tooltip.active { display: block; background-color: gray; /** all other css **/ }

For the little triangle, I used the css where I found in css trick: https://css-tricks.com/snippets/css/css-triangle/

This chunk of code works for me:

.arrow-down { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 20px solid #f00; }

Hope these information helped!

2

Thiago Adomaitis• 195

@tadomaitis

Posted

@zuolizhu Hey, hello.

Yeah, I think I did same way you did. I was curious to know other ways, but I went a very similar way (I think).

0
Connor Z• 5,115

@zuolizhu

Posted

@tadomaitis Another way I saw people did is using pure HTML and CSS. Instead of using button, changing the button to a check box, when clicked the button, which toggled the check status to checked, then add css like what we did in "active" class.

1
Thiago Adomaitis• 195

@tadomaitis

Posted

@zuolizhu I didn't know this was even possible. Probably I gonna try it sometime.

0

Please log in to post a comment

Log in with GitHub
Discord logo

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