1

I am making a website with a lot of absolutely positioned elements. I have them contained in a "page wrap" that is centered on the page. It is relatively positioned so the contained elements are laid out relative to it. Certain elements on the page are anchors to other pages and, on :hover, these elements transition to another state that makes them appear to be lifted off the page using a scale transformation and an increased box shadow.

However, when I hover over one such element, all those that follow it in the markup exhibit strange behavior such as slightly shifting position during the transition. This issue does not occur if they are not contained in the page wrap or if the page wrap is no longer set as relatively positioned (basically the same thing from a layout perspective in this case).

It seems to me as though the fact that the page wrap is centering these elements and then they are laid out relative to it is somehow affecting the rendering of the transitions, but I'm completely stuck. I've tried everything I can think of and am now reaching out for some help. Also I should say that I've only tested this on Webkit browsers so the issue may not occur on other browsers.

Here's some stripped down code:

HTML:

<body> <div id="page-wrap"> <a class="card" href="text.html"><div class="vert"><div class="card-content"> Here is<br/>some text </div></div></a> <a class="card" href="somemore.html"><div class="vert"><div class="card-content"> Here is<br/>some more text </div></div></a> <a class="card" href="evenmore.html"><div class="vert"><div class="card-content"> Here is<br/>even more text </div></div></a> </div> </body> 

CSS:

body { background: hsl(60, 80%, 90%); } #page-wrap { margin: 0 auto; position: relative; width: 800px; } .card { background: hsl(80, 0%, 97%); box-shadow: 0 1px 7px hsla(0,0%,0%,.2); display: table; height: 150px; margin: 0px; position: absolute; width: 300px; -webkit-transition: all 0.2s linear; } .vert { display: table-cell; margin 0px; padding: 0px; vertical-align: middle; width: 100%; } .card-content { font: 40px 'Annie Use Your Telescope', cursive; margin: 0px; text-align: center; width: 100%; } a.card { background: hsl(120, 90%, 35%); color: hsl(60, 80%, 90%); text-decoration: none; text-shadow: -2px 2px hsl(60, 80%, 35%); z-index: 3; } a:hover { box-shadow: 0 0 40px 15px hsla(0,0%,0%,.3); -webkit-transform: scale(1.2); } 

3 Answers 3

1

add -webkit-backface-visibility: hidden; to .card.

Already answered here.

Sign up to request clarification or add additional context in comments.

1 Comment

You're a life saver. Thank you for finding this. I looked everywhere I could for a solution.
0

Wasn't able to reproduce the problem you seem to be having. Maybe a jsfiddle.net example would be good?

When using your html & css, the divs are stacked on top of each other, removed the position: absolute; from .card and made them float:left. Didn't see any problem there, then reverted and tried adding top: and left: values to the divs and the only issue I had there was that all the divs after were above, added z-index:999 to the .card:hover and everything seemed to work just fine.

Try posting a jsfiddle.net link and I'll try to have another look at it.

1 Comment

JSFiddle of it here. It does not show up in the results window, but if you copy the HTML into a file and put the CSS in a <style> block or in its own file and open it in Chrome, you should see the problem. The code in the Fiddle directly mirrors the way the anchors are laid out.
0

I copied your code "as-is" on a CodePen.

I can't see any problem with it.

3 Comments

Posted a JSFiddle link in a comment to the above answer. See the comment for an update.
Just takes a look at your JsFiddle. No problem for me. The result is showing, and all is working fine.
The Fiddle doesn't show the issue because the results window is so small. You need to view it in a full page by copying the html and css into a file. I stated this in my comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.