4

Site: http://clientfiles.priworks.com/lgmanagedportfolios/test/investment.html

I have been working at this web page for a while now trying to get the left side of the first submenu link to line up with the left of the 1st parent/main menu link.

I don't think there is a logical way of doing it but after much fudging I am close to getting it just right. The position is consistent for all win browsers and all Mac browsers (with some conditional CSS) but not for Win and Mac browsers together, for instance in Mac Firefox the text is too far right while in Win Firefox it's perfect.

Question: Is their a way to adjust the padding specificly for Mac browsers?

Sparky
  • 98,165
  • 25
  • 199
  • 285
DevKev
  • 5,714
  • 6
  • 24
  • 29
  • 8
    I'm not exactly sure what you're talking about but a properly constructed site should look practically the same in Firefox regardless of the operating system. Also, [fix this HTML error](http://validator.w3.org/check?uri=http%3A%2F%2Fclientfiles.priworks.com%2Flgmanagedportfolios%2Ftest%2Finvestment.html&charset=%28detect+automatically%29&doctype=Inline&group=0) and see if your problem clears up before constructing a bunch of conditional CSS. – Sparky Apr 20 '12 at 13:56
  • 1
    You should really switch to a strict doctype otherwise you will see differences between browser – Fabrizio Calderan Apr 20 '12 at 14:01
  • For what it's worth, the site looks identical in FF and Safari on Mac. – Sparky Apr 20 '12 at 14:03
  • @F.Calderan, I'm not sure about that. My sites look the same cross-browser and I'm not using a strict `doctype`. – Sparky Apr 20 '12 at 14:04
  • 1
    Please post a full working URL (do not use URL shorteners) or your actual code. Right now your page is giving a 404 error. As it stands, this question will not be helpful to anyone else in the future. – Sparky Apr 20 '12 at 16:24

5 Answers5

4

I don't believe you can do this with pure css, but you can detect the OS with javascript, and then use that to load different css.

http://www.quirksmode.org/js/detect.html

axiomx11
  • 700
  • 1
  • 8
  • 15
  • This seems to be my best bet but I am using this and Mac browsers are not detecting it and using the mac.css – DevKev Apr 20 '12 at 16:44
  • structure wise you forgot the brackets {} for your if statement and the semi colon ; to end the code statement. – EnigmaMaster Apr 20 '12 at 17:40
  • Also you want to use navigator.platform , not userAgent – EnigmaMaster Apr 20 '12 at 17:44
4

You mentioned an inconsistency in text sizing/positions, have you tried using something like Eric Meyer's CSS Reset or Normalize.css? They tend to solve issues like that.

By the way, those issues with text differences are caused by Windows and Macs using different fonts as their defaults, so using your CSS to make it the same size and font family may be just what you need instead of using different stylesheets per OS.

captbrogers
  • 475
  • 5
  • 15
2

Heres the proper code for what you were trying to achieve in one of your comments above

if (navigator.platform === 'MacIntel' || navigator.platform === 'MacPPC') {
    $('head').append('<link rel="stylesheet" type="text/css" href="mac.css" />');
}​ else {
    $('head').append('<link href="main.css" rel="stylesheet" type="text/css" />');
} 

The reason your mac wasnt detecting it was that A. Your syntax was wrong and B. Looking at the source of your site if you leave <link href="main.css" rel="stylesheet" type="text/css" /> in the head section then the mac browsers are still gonna be reading that css file. Using my code above the browser will only be given the mac.css file if a mac is browsing the site or else it loads the default css

EnigmaMaster
  • 213
  • 3
  • 11
0

Use a CSS Reset sheet or normalize and it will make all the browsers display ABOUT the same by stripping the default styles

or just use * { padding: 0;} to set all padding to 0, but then you will have to set the padding for all your css

EnigmaMaster
  • 213
  • 3
  • 11
-2

Update:

You might want to use jQuery to apply CSS on fly to a particular browser on a particular OS. You will need some help from Scripting language as well.

Use $_SERVER['HTTP_USER_AGENT'] super global variable to retrieve information of the browser and OS type. Set a flag if OS = LION and browser is Safari.

Use this flag in jQuery to apply CSS only if the flag is set.

Old Answer:

This would be CSS for Safari and Chrome, but will also affect the same browsers on a Windows plateform also.

Safari and google chrome use the same engine called webkit. You can target these two browsers using

-webkit-properties

check out this link

Here is a list of webkit properties, you can use.

some examples

-webkit-animation
-webkit-animation-delay
-webkit-animation-direction

They are mostly advance properties though, not basic.

TheTechGuy
  • 16,560
  • 16
  • 115
  • 136
  • That's for special webkit only properties. It will have no effect on Firefox, nor can it be applied to just any CSS property. – Sparky Apr 20 '12 at 13:57
  • And it would target Chrome/Safari/Other webkit browsers on non-mac platforms including Windows and Android. – Quentin Apr 20 '12 at 13:58
  • I had same css with and it was displayed in chrome (windows) differently then in safari (mac). – Stan Apr 20 '12 at 13:58
  • Yes it will affect all webkit browsers. But presumely it will fix the same problem in all browsers not just safari. Since they essentially behave in same way. – TheTechGuy Apr 20 '12 at 14:00
  • Thanks CrocHunter, I had webkit property in for Chrome but when I double checked it I had some improper syntax which fixed this for Mac Chrome. – DevKev Apr 20 '12 at 14:04
  • So now the only issue is Mac FF. I am not sure why the padding is different for FF mac vs windows – DevKev Apr 20 '12 at 14:05
  • 2
    **Quote:** _"Since they essentially behave in same way."_ Yes, they _should_ but that's not what the OP was reporting. – Sparky Apr 20 '12 at 14:06
  • @KevinW.me, I see you did [not fix this error yet](http://validator.w3.org/check?uri=http%3A%2F%2Fclientfiles.priworks.com%2Flgmanagedportfolios%2Ftest%2Finvestment.html&charset=%28detect+automatically%29&doctype=Inline&group=0) in your demo. – Sparky Apr 20 '12 at 14:07
  • I did not, I just noticed the webkit affects windows. I need to target OS + browser so axiomix javascript method. – DevKev Apr 20 '12 at 14:18
  • To target OS + browser. Use jQuery with your scripting language to apply CSS on fly. – TheTechGuy Apr 20 '12 at 14:31