positioning with CSS

This is a discussion on "positioning with CSS" within the Web Page Design section. This forum, and the thread "positioning with CSS are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 22nd, 2007, 10:27
SuperMember

SuperMember
Join Date: Apr 2007
Location: UK
Age: 31
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
positioning with CSS

Hi Guys

I am just starting my first web site for my dads artwork. i'm working on the Home Page and I want to do it in the correct manner by using CSS for layout.

So far I have a banner, a navbar and a flash element underneath. The banner and navbar are centre aligned by using the text-align:center in the <body>tag in the CSS file. The problem is I want to position the flash element directly underneath the navbar but I can't seem to get it in sync. I have used the position:absolute rule. It looks like it's centred but then changes position when I maximise the window of the browser.

Could anybody offer any advice on the positioning for me? Link to the file is below.

Thanks,

Craig

http://uk.geocities.com/johnson463@btinternet.com/
Reply With Quote

  #2 (permalink)  
Old Apr 22nd, 2007, 12:45
Reputable Member
Join Date: Dec 2005
Location: scotland
Age: 27
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning with CSS

try adding

margin : 0 auto;

to any element you want to center. absolute positioning is never a good way to go.
Reply With Quote
  #3 (permalink)  
Old Apr 22nd, 2007, 13:13
SuperMember

SuperMember
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning with CSS

Hey Craig, since this is your first design, I'm going to show you how I'd do it.

Here's your new css
Code: Select all
body {

    background-attachment: fixed;

    background-color: #FFFFFF;

    background-image: url(background.gif);

    background-repeat: no-repeat;

    margin: 0 auto;

}





.navbar {
    font-family: Verdana, sans-serif;
    font-size: 16px;
    font-style: normal;
    font-weight: bold;
    color: #FFFFFF;
    background-color: #330000;
    display: inline;
    padding-right: 32px;
    padding-left: 32px;
    text-decoration: none;
    text-align: center;
    

}



.navbar:hover {

    font-family: Verdana, sans-serif;

    font-size: 16px;

    font-style: normal;

    font-weight: bold;

    color: #FFFFFF;

    background-color: #CC6600;

    display: inline;

    padding-left: 32px;

    padding-right: 32px;

    text-decoration: none;

}

#container {
    margin: 0 auto;
    width: 700px;
    text-align: center;
    
    }
#middlecontainer {
    width: 700px;
    margin: 0 auto;
    background: #EFE6C5;
    text-align: left;
    }
And this is what I'd suggest for your html

Code: Select all
<body>
<div id="container">

<img src="optwaterhome.gif" width="700" height="90" alt="banner" /> <a href="watercolour.html" class="navbar">HOME</a> <a href="optwaterhome.gif" class="navbar">GALLERY</a> <a href="optwaterhome.gif" class="navbar">ABOUT THE ARTIST</a> <a href="optwaterhome.gif" class="navbar">CONTACT US</a>
</div>
  
<div id="middlecontainer">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="365" height="255">

      <param name="movie" value="Untitled-5.swf" />
      <param name="quality" value="high" />
      <embed src="Untitled-5.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="365" height="255"></embed>   
</object>
   
  
</div>

</body>
Check this out and if you have any questions, let me know.

Last edited by Lchad; Apr 22nd, 2007 at 13:14. Reason: hit submit too quickly
Reply With Quote
  #4 (permalink)  
Old Apr 22nd, 2007, 16:47
SuperMember

SuperMember
Join Date: Apr 2007
Location: UK
Age: 31
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning with CSS

Thanks LChad. That seems to do the trick but in Internet Explorer the whole page is aligned left. In Firefox & Netscape the page seems to be centred as desired. Any ideas?

Also, this isn't anything majorly wrong but in the division that holds the flash animation do you know why there is a bit of the beigey background color showing under the flash part?
Reply With Quote
  #5 (permalink)  
Old Apr 22nd, 2007, 19:00
SuperMember

SuperMember
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning with CSS

Add to your css
html {
margin: 0;
padding: 0;
}

That might also take care of the extra spacing near the flash. I can't actually test that because I don't have your flash. If that doesn't work play with adding overflow: hidden; to the maincontent div. (or is it overflow: visible;?)
try both
Reply With Quote
  #6 (permalink)  
Old Apr 22nd, 2007, 19:30
SuperMember

SuperMember
Join Date: Apr 2007
Location: UK
Age: 31
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning with CSS

I added that rule to the css and the overflow bit but the page is still aligned left in Internet Explorer. And still has the space under the flash too! Weirdly though the space under the flash animation only seems to be apparent in Firefox & Netscape!!
http://uk.geocities.com/johnson463@btinternet.com/

Last edited by Craigj1303; Apr 22nd, 2007 at 20:11.
Reply With Quote
  #7 (permalink)  
Old Apr 22nd, 2007, 21:59
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,763
Blog Entries: 1
Thanks: 0
Thanked 18 Times in 18 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: positioning with CSS

What version of Internet Explorer?
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #8 (permalink)  
Old Apr 22nd, 2007, 22:28
SuperMember

SuperMember
Join Date: Apr 2007
Location: UK
Age: 31
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning with CSS

Version 7, on windows XP


Quote:
Originally Posted by Lchad
This isn't going to center your site in IE but I saw an unnecessary div.
Delete your #flash div and change your css of your #middlecontainer to this
Code: Select all
#middlecontainer {
    width: 700px;
    margin: 0 auto;
    background: #EFE6C5;
    text-align: left;
    }
In the html change the code around the Flash to this:
Code: Select all
<div id="middlecontainer">FLASH INFO HERE</div>
I played with your code and I have it perfectly centered in IE. The only difference between my code and yours is the javascript. Try a test run. Delete the javascript and see if it centers the design. If it does center, you know your javascript is the problem.
Quote:
<!-- following code added by server. PLEASE REMOVE -->
<script language="JavaScript" src="http://uk.geocities.com/js_source/ygNSLib9.js?v3"></script><script language="JavaScript">var yvnContents='http://geocities.yahoo.com/themis/as.php?cc=uk&s=382106086&l=NE&b=0&t=1177278850';yv nR='uk';yfnEA(0);</script>
<!-- preceding code added by server. PLEASE REMOVE -->
and
Quote:
!-- text below generated by server. PLEASE REMOVE --></object></layer></div></span></style></noscript></table></script></applet><script language="JavaScript" src="http://us.i1.yimg.com/us.yimg.com/i/mc/mc.js"></script><script language="JavaScript" src="http://geocities.com/js_source/geov2.js"></script><script language="javascript">geovisit();</script><noscript><img src="http://visit.geocities.yahoo.com/visit.gif?uk1177278850" alt="setstats" border="0" width="1" height="1"></noscript>
<IMG SRC="http://geo.yahoo.com/serv?s=382106086&t=1177278850&f=uk-w58" ALT=1 WIDTH=1 HEIGHT=1>
You'll have to post a question in the javascript forum because I have no clue about that.

Try adding this to your css code as well:
Code: Select all
* {
margin: 0;
padding:0;
}
If deleting the flash div doesn't straighten out your extra space below the flash, try adding a height of 255px to the #middlecontainer div

Some of this is trial and error...

I got rid of that flash div hours ago and the middlecontainer was already coded as you suggested from earlier.

As for the Script, that seems to be something that is added to my HTML by my service provider when I upload. It's really annoying . It's only webspace provided by them, not a proper host. However, even when I run the HTML from my PC local site, without the script it still aligns left!

Also, neither deleting the flash div or making the middlecontainer: height 255px got rid of the extra space below the flash animation

Last edited by Craigj1303; Apr 22nd, 2007 at 22:50. Reason: added comments from LChad
Reply With Quote
  #9 (permalink)  
Old Apr 24th, 2007, 15:03
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,763
Blog Entries: 1
Thanks: 0
Thanked 18 Times in 18 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: positioning with CSS

The problem with embedding flash is you have to use some javascript to bypass IE's active X sillyness. bleh.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
Reply

Tags
css

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS and positioning djme Web Page Design 6 Feb 3rd, 2006 13:27
Positioning with CSS Tino Web Page Design 8 Jan 21st, 2006 15:45
css positioning ivyholly Web Page Design 14 Dec 20th, 2005 18:43
Positioning with css Hub Web Page Design 12 Dec 13th, 2005 19:45
div positioning benbacardi Web Page Design 10 May 24th, 2004 12:25


All times are GMT. The time now is 00:36.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43