| | |
Firefox background-position problem solved
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 120
I had a background image for one of the container divs in my page. I positioned it to a specific pixel using its style properties. It worked fine in the internet explorer but was located to a wrong position when displayed by firefox. So i wrote the following code to get around this problem, it worked.
I insert the following script right after the container div.
This approach can be applied to all style conflicts between firefox and internet explorer.
html Syntax (Toggle Plain Text)
<div id="container" style="background-image: url(images/navigationMenut/left-tile.jpg);background-repeat: no-repeat; background-position: left 109px;"> </div>
I insert the following script right after the container div.
html Syntax (Toggle Plain Text)
<script> // checks the browser type to see if it is firefox if (navigator.appName.indexOf('Netscape') != -1) { // changes the position accordingly document.getElementById('container').style.backgroundPosition = "left 107px"; } </script>
This approach can be applied to all style conflicts between firefox and internet explorer.
Last edited by peter_budo; Mar 12th, 2008 at 1:46 pm. Reason: Keep It Organized - please use [code] tags
Due to lack of freedom of speech, i no longer post on this website.
•
•
Join Date: Apr 2009
Posts: 1
Reputation:
Solved Threads: 1
•
•
•
•
I had a background image for one of the container divs in my page. I positioned it to a specific pixel using its style properties. It worked fine in the internet explorer but was located to a wrong position when displayed by firefox. So i wrote the following code to get around this problem, it worked.
html Syntax (Toggle Plain Text)
<div id="container" style="background-image: url(images/navigationMenut/left-tile.jpg);background-repeat: no-repeat; background-position: left 109px;"> </div>
I insert the following script right after the container div.
html Syntax (Toggle Plain Text)
<script> // checks the browser type to see if it is firefox if (navigator.appName.indexOf('Netscape') != -1) { // changes the position accordingly document.getElementById('container').style.backgroundPosition = "left 107px"; } </script>
This approach can be applied to all style conflicts between firefox and internet explorer.
This works for Firefox and Internet Explorer did not check it on Safari or any of the other browsers
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
Y-positioning with a "bottom"-value is still a problem in Firefox. The solution is to first set height = "100%"! Example...
html Syntax (Toggle Plain Text)
<script type="text/javascript"> //...For example you set the background in fram x to bottom-right... bFn = getElementsByAttribute(top.frames[x].document,"body","background")[0]; bFn.style.margin = "0"; bFn.style.padding = "0"; bFn.style.width = "100%"; bFn.style.height = "100%"; // <<< important bFn.style.backgroundRepeat = "no-repeat"; bFn.style.backgroundPosition = "right bottom"; //x y </script>
Last edited by TempName6234572; Oct 20th, 2009 at 3:39 pm.
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Please explain the codes
- Next Thread: dropdown menu pulling xml data
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate api automatically blackjack browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element embed engine events explorer ext file firehose flash form forms game google gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft object onerror onmouseoutdivproblem onreadystatechange parent paypal pdf php player post progressbar rated regex runtime scroll search security session shopping size software sql star stars stretch synchronous text textarea tweet twitter unicode validation web webservice website window windowsxp wysiwyg \n






