Jump to content

Php Browser Compatibility. How To Make It So Different Css Is Applied For Different Browser?


cjy8s
 Share

Recommended Posts

How do i make it so a text box is positioned in a certain way for certain browsers?I have a text box that is positioned in the centered in my web page, and the text in the box is centered as well. I did this using px's however, because i could not get it to center for me otherwise. In firefox it requires me to position it -67px, but in google chrome it is centered at 6px. here is the CSS for that section:

.loginboxdiv {	margin-left:auto;	margin-right:auto;	height: 21px;	width: 146px;	background: url(Buttons/login_bg.gif) no-repeat bottom;	text-align: center;	}.loginbox {	background: none;	border: none;	position: absolute;	margin-left: 		<?php			if ($o == "WIN" && $b == "IE" && $v < 6) echo "-67px;"			else echo "6px;";		?> 	background: none;	width: 134px;	height: 15px;	margin-top: 3px;	margin-left: 6px;	padding: 2px 7px 0px 7px;	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 11px;	text-align: center;	z-index: 1;	}

I tried to use some PHP to fix this, but it didn't work. I dont know enough about this language to know how to fix it. Here is a link that i put in the <head> tags in my HTML document to a PHP document:

<link rel="stylesheet" type="text/css" href="styles.php"/>...<!-- login text boxes --><h4>Username</h4><div class="loginboxdiv" align="center">  <input class="loginbox" name="username" type="text"/></div><h4>Password</h4><div class="loginboxdiv">  <input class="loginbox" name="password" type="password"/></div>

and finally the PHP document:

<?phpheader("Content-type: text/css");$d = detect();$b = $d['browser'];$v = $d['version'];$o = $d['os'];function detect()	{	$browser = array ("IE","OPERA","MOZILLA","NETSCAPE","FIREFOX","SAFARI");	$os = array ("WIN","MAC");	$info['browser'] = "OTHER";	$info['os'] = "OTHER";	foreach ($browser as $parent)		{		$s = strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), $parent);		$f = $s + strlen($parent);		$version = substr($_SERVER['HTTP_USER_AGENT'], $f, 5);		$version = preg_replace('/[^0-9,.]/','',$version);		if ($s)			{			$info['browser'] = $parent;			$info['version'] = $version;			}		}	foreach ($os as $val)		{		if (eregi($val,strtoupper($_SERVER['HTTP_USER_AGENT']))) $info['os'] = $val;		}	return $info;	}?><?php if ($b != "OTHER" && $o != "OTHER" && $v >= 5) { ?>

This is something I don't know how to fix and don't have anyone to ask advice for. Could someone help me?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...