SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    compatability between firefox and IE

    I have a need to put a phone number in a web page. Each individual digit that comprises the phone number is actually an image created in Photoshop. So, I built the phone number by positioning each image using absolute values to place them in order. I felt for some reason that it would be easier to code the style info inline with the HTML rather than in the CSS file. The code is listed below.


    <div id="phone">

    <img src="About_us_files/re1.gif" alt="" style="height: 46px; left: 419px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re8.gif" alt="" style="height: 46px; left: 471px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re0.gif" alt="" style="height: 46px; left: 508px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re0.gif" alt="" style="height: 46px; left: 544px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re2.gif" alt="" style="height: 46px; left: 603px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re5.gif" alt="" style="height: 46px; left: 642px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re5.gif" alt="" style="height: 46px; left: 680px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re2.gif" alt="" style="height: 46px; left: 737px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re7.gif" alt="" style="height: 46px; left: 776px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re9.gif" alt="" style="height: 46px; left: 814px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    <img src="About_us_files/re6.gif" alt="" style="height: 46px; left: 851px; position: absolute; top: 1070px; width: 38px; z-index: 1; ">

    </div>

    The code works fine when I view it in Firefox, with the most important attribute being that the phone number is centered on the page (roughly). But, when I view it in IE the number is all the way over to the right side of the page not even close to centered.

    any help on how to deal with this would be great!

    Bill

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,592
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by willyd57 View Post
    I felt for some reason that it would be easier to code the style info inline with the HTML rather than in the CSS file.
    Hm, that makes for a lot of redundant code that's harder to update—especially if you have this on multiple pages. Also, your method of positioning this is going to fail in a lot of situations anyway, as positioning something in relation to the browser window is fraught with problems.

    If you show us this in context, we can provide a better way to do this. Preferably post a link to your site, or post the page code here (but test the code first to make sure if gives us a clear idea of the page layout.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the helping hand. The code I have is just on my development box and not out on the web as yet. but the reason I am writing this, is to replace an existing page. You can see that page at www.andersonhorsetransportation.com. on that site you will not see any problem with the phone number which is on a page called "About_us". You will see it at the top of the page as a nav button.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,592
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by willyd57 View Post
    you will not see any problem with the phone number which is on a page called "About_us".
    As outdated as the code is on that page, the number positioning works because it is carefully placed in relation to the other content. It is inside a container 700px wide, and that container has "position: relative", which gives a better positioning context. It's also inside another div with position: absolute, so ultimately, the numbers are positioned in relation to that box. But either way, when using position: absolute, you need a container around that—which holds its natural place in the document flow—that is set to position: relative.

    You can observe the HTML/CSS relationship of the page elements by using the web developer tools in your browser. For example, right click on your page and select Inspect Element in Chrome.

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,784
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by willyd57 View Post
    I have a need to put a phone number in a web page. Each individual digit that comprises the phone number is actually an image created in Photoshop.
    Why didn't you create the whole number as a single image? What's the benefit of having multiple images? Unless there's a good reason for it then one image would be the better choice.

    You are making the browsers fetch multiple images when one would have been suitable and a much smaller file size than the multiple images anyway. Then all you need to do is center one image which can be done simply with text-align:center on the parent and no extra rules. This cuts your code down by about 1000% percent.

    Secondly it looks as though this number is one of the most important things you want people to see yet should images be turned off then no one will see it. Screen readers get nothing as you supplied no alt attribute and devices that read and dial phone numbers (iphones etc) will not be able to auto dial for their users. Also users that have the skype add on will not be able to dial and lastly those users that want to use copy and paste can't do it either because it is an image.

    For content you should at least be adding the information into the alt attribute to make it accessible.

    I would have used an image replacement technique instead.



    But, when I view it in IE the number is all the way over to the right side of the page not even close to centered
    You have not supplied any co-ordinates for the left position so IE will determine that to be where it thinks it is depending on the text-alignment of the parent. If the text has been centred or right aligned then the auto position will be offset to the center or the right unlike other browsers.

    You could have just given your div a width and height to match the number's total width and then centred it with auto margins. The images could then have just been floated:left with one css rule.

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I have come to a conclusion, and fixed this problem in the best way possible after listening to everyone's input. For Paul's information, I did not do the original design work on this page. so the phone number being broken down like it is was not my idea, but still you make a very valid point.

    So I did some work in Photoshop and put all the individual gif images into one single jpg file that is not the phone number. Then, centering it in CSS was a simple matter of telling it the size of the phone number and used auto margins, left and right. Bingo it works. AND the whole thing is much simpler. I have one more problem to solve and my work is done. so look for my next thread, it's going to be a real head scratchier I promise.

  7. #7
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,784
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Glad you got it working


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •