Click here to Skip to main content
15,883,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
If I want to have the same size or screen resolution as 1024 * 768 for all my html pages how can I do that?
Posted

1 solution

Contain the page content in a div and set the width and height to 1024 by 768 pixels.
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <style type="text/css">
.fixedSize
{
    width:1024px;
    height:768px;
    /* use the below to centre the div */
    margin-left:auto;
    margin-right:auto;
    /* set the background to red so we can see the div */
    background:#ff0000;
}
</style>
</head>
<body>
<div class="fixedSize">
<p>Fixed Size!</p>
</div>
</body>
</html>
 
Share this answer
 
v2
Comments
Chiranthaka Sampath 24-Oct-11 5:14am    
I tried this but it does not work as I wish!.Give me some sample code for this please!
Dave Kerr 24-Oct-11 5:46am    
No probs, I've updated the solution with an example, centralized 1024x768 div.
Sergey Alexandrovich Kryukov 24-Oct-11 20:57pm    
Good solution of centralized; this is a subtle topic. My 5!
--SA
Chiranthaka Sampath 25-Oct-11 4:20am    
I tried this but face a trouble that when I set the width to 1024 the window came restored down. But when the page maximized the web page does not centered. Please kind to solve this!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900