Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question logo not staying when website is resized

    Hi,

    I want everything where it should when a user has a different screen resolution. My laptop is currently on 1400x1050 and the logo should be flush like this:


    But when I resize the page the logo(top left) moves left or right. I want it to stay the same as it should be in the image shown above.

    Heres my code for the index.html:
    Code:
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Wilbert Lati's Portfolio Website</title>
    <link href="test.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    
    -->
    </style>
    </head>
    
    <body>
    
    <div id="centre">
    <div id="Layer1"><img src="images/swirl background.jpg" /></div>
    <div id="Layer2"><img src="images/wilbert lati_logo_v2.jpg" /></div>
    </div>
    
    </body>
    
    </html>
    and this is the code for the css:
    Code:
    #background {
    	position:absolute;
    	width:1024;
    	height:768;
    	z-index:1;
    	visibility: visible;
    }
    #Layer1 {
    	position:absolute;
    	width:1024px;
    	height:768px;
    	z-index:1;
    	visibility: visible;
    }
    #Layer2 {
    	position:absolute;
    	width:300px;
    	height:150px;
    	z-index:2;
    	top:20px;
    	left:205px;
    	visibility: visible;
    }
    #centre
    {
    	width: 1024px;	
    	text-align: center;
    	position: realtive;
    	left: 50%;
    	top: 50%;
    	margin-top: 0px;
    	margin-right: auto;
    	margin-bottom: 0px;
    	margin-left: auto;
    }
    Heres a link to the files:
    http://www.megafileupload.com/en/fil...bsite-zip.html

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,672
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello wblati,
    I always think it's unfortunate that DW kind of steers new coders toward using so much absolute positioning. I hate the use of #layer1/2/3 ... but that's just my pet peeve.

    Your main problem is the containing div is not position:relative; which makes the absolute positioned top left logo take it's positioning from the body of the document. That's why your seeing it move when the resolution changes.
    Fix this spelling error and it works, somewhat. -
    Code:
    #centre
    {
    	width: 1024px;	
    	text-align: center;
    	position: realtive;
    	left: 50%;
    	top: 50%;
    	margin-top: 0px;
    	margin-right: auto;
    	margin-bottom: 0px;
    	margin-left: auto;
    }
    Your use of positioning kind of negates the margin: 0 auto; and by placing #centre at 50% you lose a lot of the viewport.

    There are much better ways to do this - have a look at this -
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Wilbert Lati's Portfolio Website</title>
    <style type="text/css">
    html, body {
    	font: 100% "Comic Sans MS";
    	background: #FC6;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: 0;
    }
    #centre {
    	height: 768px;
    	width: 1024px;	
    	margin: 0 auto;
    	background: url(images/swirl%20background.jpg);
    	text-align: center;
    	overflow: auto;
    }
    #logo {
    	height:150px;
    	width:300px;
    	float: left;
    	top:20px;
    	left:205px;
    	margin: 20px 0 0 205px;
    }
    </style>
    </head>
    <body>
        <div id="centre">
        	<img src="images/wilbert lati_logo_v2.jpg" alt="description" width="300" height="150" id="logo" />
        <!--end centre--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks alot Excavator!

    Am I doing alright coding wise? Any adivice/ tips as I'm updating my old website(www.wilbertlati.co.uk) with this new one.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,672
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Quote Originally Posted by wblati View Post
    Thanks alot Excavator!

    Am I doing alright coding wise? Any adivice/ tips as I'm updating my old website(www.wilbertlati.co.uk) with this new one.

    You seem to have the right idea, getting away from frames and using a linked CSS that can style multiple pages.
    I would question the use of absolute positioning, it has it's place but it's surely not needed to build the whole site with.
    Also, check with w3schools for tutorials on any selectors you're not familiar with, use the validators like my signature line suggests and post back here when you run into something that stumps you.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

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