Is it possible to target Chrome only, not all Webkit powered browsers?
There are browser-specific CSS hacks that might work for this problem now, but they certainly aren't supported.
IMHO, your best bet is to add a class to the body tag using JavaScript that reads your navigator.userAgent and use that class (body.chrome for example) to target Chrome.
Can you target Google Chrome?
@media screen and (-webkit-min-device-pixel-ratio:0) {
/*Chrome CSS here*/
#cartUpdate {
position:absolute;
width:160px;
height:30px;
left:660px;
bottom:40px;
}
}
Fixed the problem :)
UPDATE
This resource works better: CSS browser/OS selectors with JS.
How can I achieve a consistent layout in all browsers?
I find the best policy to avoid pain is to follow these rules:
- Build in a more-compliant and developer-friendly browser like firefox first, test thoroughly in IE (and safari/chrome(webkit) and opera) periodically.
- Use a strict doctype- you don't necessarily need perfect markup, but it should be very good — good enough to avoid browser quirks modes, since quirks are by definition not standard
- Use a reset style sheet. Note that depending on the sheet's contents this item may be incompatible with the goal of #2.
- Use a javascript framework like jQuery or Prototype - they can hide some javascript and DOM incompatibilities.
- Use good semantic layout- it's more likely to degrade nicely for a mis-behaving browser
- Accept that it won't be perfect and don't sweat the really small variances
Follow those rules and there aren't as many problems in the first place.
For a TODO reference, see this question:
https://stackoverflow.com/questions/72394/what-should-a-developer-know-before-building-a-public-web-site
Chrome conditional comments
You can target WebKit based browsers using this in your CSS
@media screen and (-webkit-min-device-pixel-ratio:0) {
Body {}
}
Perhaps this will help?
How do I add a css line ONLY for Safari
This is not possible since you would be applying the same property to Chrome as well. As Chrome, and Safari both use the -webkit- prefix.
But you could do this in PHP.
<?php
$browser = get_browser();
if(strtolower($browser->browser) == 'safari') {
echo '<link href="safari.css" rel="stylesheet" type="text/css" />';
}
?>
Replace safari.css with your own stylesheet. Credit to @theorise
Related Topics
CSS Hover Over on Thumbnails in Wordpress
Multiple Divs with The Same Id Invalid
Using Rems with a Pixel Fallback
How to Center Text Horizontally and Vertically in Cojunction with 'Writing-Mode: Sideways-Lr'
How to Create a Partial Border(With a Hole)
Whats Wrong with The Media Query
Rounded Bottom Div Where Curve Angle Is Not Responsive
How to Prevent Ggplot Hoveropts Messages to Go Off Screen with CSS
Select All Block Level Elements with CSS
Does Display:None Still Use Performance of Rendering
Why Does Chrome Read The Svg Circle Radius from The Style Attribute