1

I'm looking to create something akin to the Mac App Dock. Basically, I have an number of divs all next to each other with the same class, and a unique ID (done through php).

Currently, when you hover over one element, it magnifies it using transform, however this doesn't affect the elements adjacent to them.

I'm wondering if there's a way to essentially make it so item-2 has a hover effect of transform:scale(2.0), and upon hovering over that element, item-1 & item-3 would get an effect of transform:scale(1.5);

Although, I imagine this is impossible in css. If so, is there a way I can achieve this effect in php or javascript somehow?

3
  • Yes, you can do this using Javascript. Commented Mar 24, 2014 at 20:37
  • can you add your code and a jsfiddle ? Commented Mar 24, 2014 at 20:38
  • Check out this vid, when not related to the dock, I have often seen this affect called a "tsunami" youtube.com/watch?v=P1ASs40iows Commented Mar 24, 2014 at 21:52

1 Answer 1

1

This is tricky since transform: scale doesn't seem to behave consistently across browsers.

I put together some CSS and Javascript to do what you described, although making it look good on all browsers would take much more time.

Try out my demo here: CodePen

HTML

<ul id="list">
  <li><a href="#">One</a></li>
  <li><a href="#">Two</a></li>
  <li><a href="#">Three</a></li>
  <li><a href="#">Four</a></li>
  <li><a href="#">Five</a></li>
  <li><a href="#">Six</a></li>
</ul>

CSS

#list li:hover {
  zoom: 2;
  -webkit-transform: scale(2);
  -moz-transform:    scale(2);
  -ms-transform:     scale(2);
  -o-transform:      scale(2);
  transform:         scale(2);
  position: relative;
  z-index: 999;
 }
.beside {
   zoom: 1.5;
  -webkit-transform: scale(1.5);
  -moz-transform:    scale(1.5);
  -ms-transform:     scale(1.5);
  -o-transform:      scale(1.5);
  transform:         scale(1.5);
 }

Javascript (jQuery)

  $('#list li').on("mouseenter", function() {
    $(this).prev().addClass("beside");
    $(this).next().addClass("beside");
  });
  $('#list li').on("mouseleave", function() {
    $(this).prev().removeClass("beside");
    $(this).next().removeClass("beside");
  });
Sign up to request clarification or add additional context in comments.

4 Comments

Good concept, the besides don't seem to zoom though.
What browser are you using? It works for me in Chrome on Ubuntu.
@MattThompson I just tested in firefox and it doesn't work :(
I updated to make it work in Firefox, but it's not as pretty. there is some overlapping. You would have to play with the styling to tweak it to your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.