- This topic is empty.
-
AuthorPosts
-
April 25, 2014 at 2:32 am #168659
Joe
ParticipantLaunched a new version of my site a few days ago, but somehow the logo is 2px out (you can see some orange underneath).
This only happens in Chrome (not even Safari!) and even by using the inspector I can’t find whats doing it.
Can anyone spot it? It’s really bugging me!
April 25, 2014 at 2:45 am #168662Paulie_D
MemberThat’s seems to be an odd way to go about it.
You have an inline image AND a different bg image on the div.
Why not put the bg image on the link and swap it on hover?
April 25, 2014 at 2:49 am #168663Paulie_D
MemberI suspect part of the problem (other than the above) is that the images are 153px wide.
When you center one of them in the div (which is 240px wide) you get sub-pixel rendering issues as it can’t be 1/2 a px wide on each side.
April 25, 2014 at 2:55 am #168664Joe
ParticipantHi Paulie,
Thanks for two great answers – may try #1 if I can’t get it working this way.
#2 – I did think about that but applying a 2px margin-left to the image sorts the problem.
April 25, 2014 at 4:25 am #168676Joe
ParticipantStrangely, the bug does not happen on this page: http://bit.ly/1fdO9ZK :S
April 25, 2014 at 4:44 am #168677Paulie_D
MemberIt does on Chrome.
April 25, 2014 at 4:46 am #168678Paulie_D
MemberWhy not try.
.header-logo { text-align: center; background-image: none; background-position: top center; background-repeat: no-repeat; font-size: 0; } .header-logo:hover { background-image: url("/wp-content/themes/oxfordshirewebv2/images/logo-orange.png"); }
That way the orange image isn’t visible until you hover over the logo at which time the black image disappears.
April 25, 2014 at 5:04 am #168679Joe
ParticipantWhilst that does work, it looks a bit bad as it shifts by that few px on hover. Really interested as to why or how Chrome is adding these extra pixels.
April 25, 2014 at 5:11 am #168680Paulie_D
MemberAs I said, it’s probably a sub-pixel thing with some ‘bleed’.
Since Chrome can’t render 1/2 a pixel my guess is that it’s rendering an extra full pixel on all sides.
Anyway, seems to me the real problem is the inline image, Is that a WP requirement?
Because if not, you could remove it and
.header-logo { text-align: center; background-image: background-image: url("http://cdn.css-tricks.com/wp-content/themes/oxfordshirewebv2/images/logo-charcoal.png"); background-position: top center; background-repeat: no-repeat; font-size: 0; } .header-logo:hover { background-image: url("http://cdn.css-tricks.com/wp-content/themes/oxfordshirewebv2/images/logo-orange.png"); }
Although you would have to set width/height on the logo element.
April 25, 2014 at 10:09 am #168698Joe
ParticipantIt’s a responsive design so it would suck to have to do that for each breakpoint. Think attaching the image as a bg image to the anchor is probably the best solution. Very strange that it’s a Chrome only bug.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.