473,468 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Vertical alignment on large resolution

30 New Member
Hi All,

How can I align table/DIV in middle on large resolutions?

Just go to this link, my portfolio

And this on large resolution, it is coming on top of the page.

I want to align page content to middle of the browser height.

Thanks in advance
Oct 9 '06 #1
4 2328
rachwelian
3 New Member
The only way I know how to do it would be to put it in a table with valign set to "middle" and height="100%"
Oct 9 '06 #2
jaymanson
29 New Member
Here's a fairly simple trick to do this with CSS:

First, the HTML file:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5.    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6.    <title>Untitled Document</title>
  7.  
  8.    <!-- Link to your CSS style sheet here -->
  9.    <link href="test.css" rel="stylesheet" type="text/css" />
  10.  
  11. </head>
  12.  
  13. <body>
  14.  
  15.    <div id="pixel">
  16.  
  17.       <div id="wrapper">
  18.  
  19.          <!-- Put your site content in here -->
  20.  
  21.       </div>
  22.  
  23.    </div>
  24.  
  25. </body>
  26.  
  27. </html>
and the CSS:

Expand|Select|Wrap|Line Numbers
  1. /* CSS Document */
  2.  
  3. /* First we make a 1x1 pixel container div.
  4. The 50% / 50% absolute positioning centers it on the screen
  5. The overflow ensures anything inside it will spill out to fill the screen */
  6.  
  7. #pixel {
  8.     width: 1px;
  9.     height: 1px;
  10.     position: absolute;
  11.     top: 50%;
  12.     left: 50%;
  13.     overflow: visible;    
  14. }
  15.  
  16. /* Now we make the wrapper to hold your site content.
  17. It can be any width or height, but the 'right' positioning value must be 
  18. set to half the 'width' and the 'bottom' value set to half of the 'height' */
  19.  
  20. #wrapper {
  21.     width: 400px;
  22.     height: 240px;
  23.     position: relative;
  24.     right: 200px; 
  25.     bottom: 120px;
  26. }
I've put explanations inside the code. This is all CSS - no tables required :-)

Let me know if you have any problems.

- Jay
Oct 10 '06 #3
jaymanson
29 New Member
Actually, when I think about it, this would be slightly better:

Expand|Select|Wrap|Line Numbers
  1. #wrapper {
  2.     width: 400px;
  3.     height: 240px;
  4.     position: relative;
  5.     right: 50%; 
  6.     bottom: 50%;
  7. }
Setting the right and bottom values to 50% saves having to work it out (not that it's hard to half something, but it does leave less possibility for error!)

Jay
Oct 10 '06 #4
jaymanson
29 New Member
Actually, when I think about it, this would be slightly better:

Expand|Select|Wrap|Line Numbers
  1. #wrapper {
  2.     width: 400px;
  3.     height: 240px;
  4.     position: relative;
  5.     right: 50%; 
  6.     bottom: 50%;
  7. }
Setting the right and bottom values to 50% saves having to work it out (not that it's hard to half something, but it does leave less possibility for error!)

Jay
Scratch that last post - the 50% thing works in IE but not in FF! Looks like you'll have to get the calculators out and do it the first way I suggested lol

It's 1am here and obviously way past my bedtime now!
Oct 10 '06 #5

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

Similar topics

8
by: abracad | last post by:
Hi Is it possible to vertically align an image in the middle of a DIV of fixed height?
3
by: Frank Wheeler | last post by:
Why am I unable to attain proper vertical alignment between a DIV and a TABLE here: http://www.whbvillage.com/agenda-archives/agendex.html The DIV is coded: <DIV style="float: left;...
1
by: Kenneth | last post by:
Okay, I've been scouring Google for hours looking for a solution to this problem, but as of yet I can't find one. XHTML Transitional seems to specify that I can no longer set a table's height to...
67
by: S.Tobias | last post by:
I would like to check if I understand the following excerpt correctly: 6.2.5#26 (Types): All pointers to structure types shall have the same representation and alignment requirements as each...
6
by: Andy Mabbett | last post by:
Please can someone remind me of the most elegant fix for the way Firefox fails to vertically align cell content by default? For example, the second event on: ...
12
by: Yevgen Muntyan | last post by:
Hey, Consider the following code: #include <stdlib.h> #define MAGIC_NUMBER 64 void *my_malloc (size_t n) { char *result = malloc (n + MAGIC_NUMBER);
11
by: C.W.Holeman II | last post by:
I what to hide an input element and the following text. I have the selector for the input working and just need to grab the text following it. CSS: form{ display:table; text-align:center; }
8
by: ayamopamo | last post by:
Hi- I am trying to center a web page. It seems like this should be very simple to do, but apparently it isn't my day. I have successfully centered the background by calling it in the css body tag:...
13
by: Bill | last post by:
Hi How can I have IE7 act correctly on that ? The rules make the link text go down when hovered. It works in FF , I had to add a hard space right after the LI tag to have OP9 work but I can't...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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...
0
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.