![]() |
Forum Index : Microcontroller and PC projects : Web page design
Author | Message | ||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 2000 |
Hi all, this is a bit different. I have designed a web page but am having trouble getting it to fit any browser size. On my desktop it is ok but on the smaller laptop screen I have to scroll every way to see it all. I used the following code but it didn't work. It is a public site, I am new to this and get lost easily. meta name="viewport" content="width=device-width, initial-scale=1.0"> Can anyone help. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Gizmo![]() Admin Group ![]() Joined: 05/06/2004 Location: AustraliaPosts: 5132 |
The issue is some browsers ( looking at you in particular Safari ), dont necessarily take any notice of your meta tags. In my JAQ intranet application, I use the following java to resize the page to the browser window on mobile devices. Its not perfect. In the body tagI call a function like this.... <body onLoad="PageZoom();"> <div style="width:330px; margin:auto;" id="PageDiv"> Blah blah That div encases the entire page in the body tag. You can control the width with that style "width:330px", but its not necessary. In this case its a generic mobile phone width so I can check th epages looks ok on a mobile screen as I develop the page. Then elsewhere on the page, usually in the header somewhere, I have... <script language="javascript"> function PageZoom(){ var DivW=document.getElementById("PageDiv").offsetWidth; var PageW=window.innerWidth; Z= Math.round(PageW / DivW * 95); Zstring=Z.toString() + "%"; document.body.style.zoom = Zstring; document.getElementById("PageDiv").focus(); } </script> Once the page has loaded, it gets the width of the div "PageDiv", and then adjusts the zoom to suit. Glenn Edited 2025-10-05 11:27 by Gizmo The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 2000 |
I'll try that, thanks. EDIT.... That didn't work, I don't know enough about HTML ,so I can just put up with it. Edited 2025-10-05 14:20 by palcal "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |