473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS positioning problem

1 New Member
Hi,

I am using CSS to position objects (<SPAN> and <DIV> tags) on my webpage,
which is working great on regular computer monitors, when I view the same page on
a wide screen laptop monitor, one of my objects (<span id="logo">) changes
position and is placed about 5 pixels below where it suppose to be.
If I adjust the position to compensate for these five pixels,
then the object is correctly positioned on the widescreen monitor but is five pixels off on the regular monitors.
When I only use HTML TABLES with no CSS positioning, I do not grt this problem.

Below are the CSS and the HTML code.

Thank you for your help.

Expand|Select|Wrap|Line Numbers
  1. <htm>
  2.   <body>
  3.     <div id="container">
  4.       <div style="width: 1100px;">
  5.         <span id="google">
  6.           <FORM method="GET" action="http://www.google.com/search">
  7.             <input type="hidden" name="ie" value="UTF-8">
  8.             <input type="hidden" name="oe" value="UTF-8">
  9.             <A HREF="http://www.google.com">
  10.               <IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0" ALT="Google" width="80" height="20">
  11.             </A>
  12.             <INPUT TYPE="text" name="q" size="25" maxlength="255" value="">
  13.             <INPUT type="submit" name="btnG" value="Search">
  14.             <font size=-1>
  15.               <input type="hidden" name="domains" value="www.xxx.com"><br><br>
  16.               <input type="radio" name="sitesearch" value=""> Web 
  17.               <input type="radio" name="sitesearch" value="www.xxx.com" checked>xxx<br>
  18.             </font>            
  19.           </FORM>
  20.         </span>
  21.         <span id="logo2_top">
  22.           <em>XXX</em>
  23.         </span>
  24.         <span id="logo">
  25.           XXXX
  26.           &nbsp;
  27.         </span>
  28.       </div>      
  29.     </div>
  30.   </body>
  31. </html>
  32.  
  33.  
  34. //======================================
  35. // CSS
  36. //======================================
  37. BODY
  38.   color: black;
  39.   font-family: Verdana, Arial, Helvetica, sans-serif;
  40.   background-image: url('../images/background5.jpg');
  41. }
  42. #container
  43.   margin-left: auto;
  44.   margin-right: auto;
  45.   text-align: center;
  46.   top:0px; 
  47.   left:0px;
  48.   width: 100%;
  49. }
  50.  
  51. #google
  52. {
  53.   width: 375px; 
  54.   height: 80px; 
  55.   text-align: left;
  56.   background-image: url('../images/background.jpg');
  57.   position: relative; 
  58.   top:-4px; 
  59.   left:0px;      
  60. }
  61.  
  62. #logo2_top
  63. {
  64.  text-align: center;
  65.  width: 215px; 
  66.  height: 80px; 
  67.  background-image: url('../images/background.jpg');
  68.  position: relative; 
  69.  top:-4px; 
  70.  left:0px; 
  71.  vertical-align: top; 
  72.  font-family: script; 
  73.  font-weight: bolder; 
  74.  font-size: 30px; 
  75.  color:#660000;  
  76. }
  77.  
  78. #logo
  79. {
  80.   width: 375px; 
  81.   height: 80px; 
  82.   text-align: right;
  83.   background-image: url('../images/background.jpg');
  84.   position: relative; 
  85.   top:-50px; 
  86.   left:0px;
  87. }
Feb 27 '08 #1
1 1255
just a feeling
87 New Member
Hi,
There are a number of options:

1- Make a fixed width design. Set the CSS width of your body tag to the width you want in pixels (so for 800x600, width: 780px) and set the CSS margins to auto, as this will put your fixed-width page in the centre of larger screens. This is the most popular solution to the resolution problem (just design as if everyone was using 800x600 ).

2- Use javascript detection.
Expand|Select|Wrap|Line Numbers
  1. var mini = 1024;
  2. var big = 1280;
  3.  
  4. if (window.screen.availWidth == mini) {
  5.  
  6. document.write('<link rel="stylesheet" type="text/css" href="1024.css" />'); 
  7.  
  8. }
  9. else    {
  10.  
  11. document.write('<link rel="stylesheet" type="text/css" href="1280.css" />');
  12. }
3- Use 'elastic' design. If your design has three columns, for example, make the left and right columns fixed-width and leave the middle column to take up all the remaining width.

4- Use percentage. Change the widths on all of the block level elements to %.

5- Rely on the majority of visitors having a suitable resolution and leave the 1024x768 "warning" in place.

I'd favour 1, but it's up to you.
HTH,
Feb 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
2312
by: Tom Szabo | last post by:
Hi, Just wondering if there are any disadvantage in absolute positioning controls on a page? In example instead of putting the text fields into a table to align properly, one would absolute...
9
32028
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
4
2685
by: Jane Withnolastname | last post by:
I am trying to re-work an old site by replacing the html with css. On the main page, I have a logo image which I needed centred on the initial screen. I found the solution here:...
14
2451
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
6
2660
by: rajek | last post by:
I posted a similar question yesterday, but didn't get an answer that resolved the issue. (Thanks to those who tried though.) The background: I've read in books and online that if you have one...
9
1796
by: Frances Del Rio | last post by:
I have a pg with lots of divs, one of them is a gray bar about 150px down from the top and 20px from the left... this bar (an image) is 767px wide and 1px high.. however, even though all divs are...
11
2622
by: NS | last post by:
I am relativly new to css positioning and have a question regarding the display of a DHTML pop-up Here is the basic HTML I am using: <html> <head> <script language="JavaScript"> <!--
4
7798
by: TheCeej | last post by:
I'm sorry to post what is ultimately a myspace problem, but I'm sure I'd still be having this problem with any html/css document, so the answer would more than likely be able to help anyone out. I'm...
2
16395
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
2
1921
by: TheCruelPanda | last post by:
Hey there. My name is Rowan, and it's been three weeks since I last used tables for an HTML design. Okay, I'm rather new to CSS and I have a big positioning problem here. It might not be a...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.