cjy8s Posted September 27, 2009 Share Posted September 27, 2009 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 More sharing options...
Ingolme Posted September 27, 2009 Share Posted September 27, 2009 To center it, just put it in a container with text-align: center;. No need to go adding pixels. This should work: .loginboxdiv { text-align: center; } Link to comment Share on other sites More sharing options...
jlhaslip Posted September 27, 2009 Share Posted September 27, 2009 You may need to add a declaration in the CSS/php file to set the mime-type for that file so that the file is handled as a CSS file. Add it right at the top of the file before anything else. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.