/    Sign up×
Community /Pin to ProfileBookmark

Control :hover a flexbox item

This is an attempt to do a top navbar using flexbox. It seems that this could be done in a simpler way:

https://jsfiddle.net/vnLzku0q/2/

  • 1. How can I ensure that the three first items not change color when hovered?

  • 2. Is there a better way to do this?
  • to post a comment
    CSS

    5 Comments(s)

    Copy linkTweet thisAlerts:
    @SempervivumMay 04.2019 — How can I ensure that the three first items not change color when hovered?[/quote]The easiest way is assigning a class to the elements to be hovered.
    Is there a better way to do this?[/quote]Fine so far. I guess that the purpose of the empty container is to arrange the first two items to the left and the other ones to the right. This can also be achieved by applying margin-right:auto to the logo container. No auxiliary container needed.

    This link shows some advanced techniques of arranging flex items:

    https://stackoverflow.com/questions/32551291/in-css-flexbox-why-are-there-no-justify-items-and-justify-self-properties/33856609#33856609

    Modified fiddle:

    https://jsfiddle.net/Sempervivum/yLo0n9v1/6/
    Copy linkTweet thisAlerts:
    @sibertauthorMay 05.2019 — Brilliant! Thank you!

    But can I omit the "> div" when I am using a class?

    .flex-container > div.logo {

    Like this:

    .flex-container .logo {

    It seems to work without the divs

    https://jsfiddle.net/0y46bfpw/
    Copy linkTweet thisAlerts:
    @SempervivumMay 05.2019 — Yes, you can, "div" is not that important in that context.
    Copy linkTweet thisAlerts:
    @sibertauthorMay 05.2019 — Is there any way to inherit the background-color from picture when hovering?

    https://jsfiddle.net/kut5v2os/1/

    Like hovering the image but darker.
    Copy linkTweet thisAlerts:
    @SempervivumMay 05.2019 — I'm not shure what kind of effect you intend to achieve. At the right (about and magnifier) the image is very dark and a background darker would not be visible. One can simulate such effect by applying a black background and a low opacity:

    https://jsfiddle.net/Sempervivum/jtf1anrz/1/

    (Start and blog)
    ×

    Success!

    Help @sibert spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.23,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...