Current location: Hot Scripts Forums » General Web Coding » CSS » CSS float and absolute height


CSS float and absolute height

Reply
  #1 (permalink)  
Old 06-13-07, 02:49 AM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
CSS float and absolute height

In CSS:

If you create a div for the header and specify the height and a background image, the actuel height is only as "high" as the text in it.
How can you make the height absolute in pixels?
What I mean is this: http://www.kimwebsites.com/kim/ (you see the blue table headers, the underlaying picture is actually a little bigger than that).

Second of all:
I put everything in a div called center and specified that container to be text-align:center
And then the containers in between,they're all text-align: left.
But; appareantly Opera and Mozilla handle these differently than Internet Explorer.

For the left alignment of a container I used float: left; and float: right;
Again, this turns out just fine in Internet Explorer but not at all in Opera,...

Can someeone explain a few actual general css settings to me for:
centering a page but left aligning all text in it?
Creating two blocks or containers next to each other, one left the other one right.
Defining an actual precise height for a container with a background image.


Thanks,
Kim
Reply With Quote
  #2 (permalink)  
Old 06-13-07, 03:25 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
i'm not sure if it's gonna work, but you can try this to center a div:
css Code:
  1. mydiv{
  2.   margin:0 auto;
  3. }

to create to containers next to each other, you will have to specify the width of each container:
css Code:
  1. div_lef {
  2.   float:left;
  3.   width:50%;
  4. }
  5.  
  6. div_right {
  7.   float:right;
  8.   width:50%;
  9. }

to define the exact height, use the "height" option:
css Code:
  1. mydiv{
  2.   height:100%;
  3. }
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 06-13-07, 01:02 PM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
actually, I just found out the trick is:

CSS Code:
  1. margin-left: auto;
  2. margin-right: auto;
  3. width: 796px;
  4. text-align: left;

for your center div, and a text-align: left; for your body css

Still afwul in Firefox though...

My css file is:
http://www.kimwebsites.com/kim/style.css

Last edited by UnrealEd; 06-13-07 at 01:04 PM. Reason: Merged.
Reply With Quote
  #4 (permalink)  
Old 06-14-07, 02:56 PM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Still got a few problems in Firefox: top images not without spacing, footer not at all underneath (is the border part valid css?).

The alignment is fixed, I was confused whether to add the padding number or not.

HTML

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Kim Websites: Open Platform voor Professionele Websites</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>

<div class="center">


<img src="img/logo.jpg" alt="Logo Kim Websites"><img src="img/english.jpg"><img src="img/webcms1.jpg"><br /><img src="img/bedrijfswebsitecms995.jpg" alt="Logo Kim Websites"><br /><img src="img/tutorialstoolsencms.jpg" alt="Logo Kim Websites">

<h1><strong>Wat maakt ons uniek?</strong></h1>
<p class="tekst">Kim Websites innoveert door zijn software, tools en tips gratis weg te geven. Enkel voor maatwerk betaal je...de laagste prijs.<br />
<a href="#" class="bluelink">Maak kennis met commerciële open-source</a></p>

	
	<div class="homeleft">

<h2><strong>PHOTOSHOP</strong></h2>
<h1><strong>Tips voor een goede ranking</strong></h1>
<p class="datum">29/03/2007</p>
<p class="tekst">Er zijn enkele methodes die iedereen kan toepassen om de ranking of positie van zijn website te verbeteren bij zoekmachines. De tips die ik wil geven zijn geldig voor...</p><img src="img/knop.gif">

<br />

<h2><strong>PHOTOSHOP</strong></h2>
<h1><strong>Tips voor een goede ranking</strong></h1>
<p class="datum">29/03/2007</p>
<p class="tekst">Er zijn enkele methodes die iedereen kan toepassen om de ranking of positie van zijn website te verbeteren bij zoekmachines. De tips die ik wil geven zijn geldig voor...</p><img src="img/knop.gif">

<br />

<img src="img/bouwmeeprogrammeurs.jpg">

<h2><strong>PHOTOSHOP</strong></h2>
<h1><strong>Tips voor een goede ranking</strong></h1>
<p class="datum">29/03/2007</p>
<p class="tekst">Er zijn enkele methodes die iedereen kan toepassen om de ranking of positie van zijn website te verbeteren bij zoekmachines. De tips die ik wil geven zijn geldig voor...</p><img src="img/knop.gif">

<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3334368190667923";
google_alternate_color = "FFFFFF";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text";
//2007-06-12: KimWebsites
google_ad_channel = "3547524400";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "20BC0F";
google_color_text = "000000";
google_color_url = "1A7DE8";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

</div>

	<div class="homeright">
		
		<div class="tabelkop">
			<p class="kleinwit"><strong>Nieuwe Templates (Alle templates)</strong></p>
		</div>

<div class="templates">
	<br />
<div class="templatelinks">
<a href="gallery.php"><img border="0" src="img/template_001.jpg" /></a> <br />
<a href="gallery.php"><img border="0" src="img/winkelkarretje.jpg" /></a> <a href="gallery.php"><img border="0" src="img/vergrootglas.jpg" /></a>
</div>
<div class="templaterechts">
<a href="gallery.php"><img border="0" src="img/template_002.jpg" /></a> <br />
<a href="gallery.php"><img border="0" src="img/winkelkarretje.jpg" /></a> <a href="gallery.php"><img border="0" src="img/vergrootglas.jpg" /></a>
	<br />
</div>




		</div>
		<br />	<br />
				<div class="tabelkop">
			<p class="kleinwit"><strong>Download Kim Website 1.0</strong></p>
		</div>
		<div class="tabel">
			<p class="tekst">
Content Management System gebaseerd op PHP en MySQL. Tal van functies: nieuws, columns, leden, online mailings, beveiliging, enquêtes,...
</p>
<p align="center"><img src="img/download.gif"></p>
<a href="#" class="bluelink">Wij hosten en installeren voor € 9,95/maand</a>

</div>

<br />	<br />
				<div class="tabelkop">
			<p class="kleinwit"><strong>Betaalde diensten</strong></p>
		</div>
		<div class="tabel">
			<p class="tekst">
> Professioneel ontwerp op maat<br />
> User-centered design<br />
> Zoekmachineoptimalisatie<br />
> Hosting<br />
> Beheer en onderhoud<br />
> Online mailings</p>
<br /><a href="#" class="bluelink">Een professionele site voor uw bedrijf slechts € 995</a>
</div>


</div>



<div class="footer">
<p class="tekst">&copy 2006-2007 VH Technology</p>
</div>

</div>

</body>
</html>
CSS

css Code:
  1. body {
  2.     padding: 0px;
  3.     margin: 0px;
  4.     text-align: center
  5. }
  6.  
  7. h1 {
  8.     color: #1A7DE8;
  9.     font-family: arial;
  10.     font-size: 1.2em;
  11.     margin: 0px;
  12. }
  13.  
  14. h2 {
  15.     color: #20BC0F;
  16.     font-family: arial;
  17.     font-size: 0.8em;
  18.     margin: 0px;
  19. }
  20.  
  21. h3 {
  22.     color: #fff;
  23.     font-family: arial;
  24.     font-size: 0.85em;
  25. }
  26.  
  27. p {
  28.     margin: 0px;
  29. }
  30.  
  31.  
  32. div.center {
  33.     padding: 0px;
  34.     margin-left: auto;
  35.     margin-right: auto;
  36.     width: 796px;
  37.     text-align: left;
  38. }
  39.  
  40. .tekst {
  41.     color: #000000;
  42.     font-size: 0.75em;
  43.     font-family: Arial;
  44.     text-align: left;
  45. }
  46.  
  47.  
  48. div.home {
  49.     margin: 0px;
  50.     padding: 0px;
  51.     width: 796px;
  52.  
  53. }
  54.  
  55. div.homeleft {
  56.     width: 436px;
  57.     margin: 0px;
  58.     padding: 0px;
  59.     float: left;
  60.     text-align: left;
  61. }
  62.  
  63. div.homeright {
  64.     width: 360px;
  65.     margin: 0px;
  66.     padding: 0px;
  67.     float: right;
  68.     text-align: left;
  69. }
  70.  
  71. div.tabelkop {
  72.     width: 360px;
  73.     height: 25px;
  74.     margin: 0px;
  75.     padding: 0px;
  76.     background-image: url(img/tabelkop.jpg);
  77. }
  78.  
  79. div.tabel {
  80.     width: 360px;
  81.     margin: 0px;
  82.     padding: 0px;
  83.     background-color: #ECEDEF;
  84. }
  85.  
  86. .datum {
  87.     color: #B8B8B8;
  88.     font-size: 0.7em;
  89.     font-family: Arial;
  90.     text-decoration:bold;
  91. }
  92.  
  93. .kleinwit {
  94.     color: #FFFFFF;
  95.     font-size: 0.85em;
  96.     font-family: Arial;
  97.     margin-left: 15px;
  98. }
  99.  
  100. div.templates {
  101.     width: 360px;
  102.     height: 150px;
  103.     margin: 0px;
  104.     padding: 0px;
  105.     background-color: #ECEDEF;
  106. }
  107.  
  108. div.templaterechts {
  109.     width: 150px;
  110.     text-align: right;
  111.     margin-right: 30px;
  112.     padding: 0px;
  113.     float: right;
  114. }
  115.  
  116. div.templatelinks {
  117.     text-align: right;
  118.     width: 150px;
  119.     margin: 0px;
  120.     padding: 0px;
  121.     float: left;
  122. }
  123.  
  124. div.footer {
  125.     border-top: 1px solid #4874D3;
  126.     padding: 0px;
  127.     width: 796px;
  128.     text-align: right;
  129. }
  130.  
  131. a.bluelink:link
  132. { color: 1A7DE8; font-family: arial; font-size: 1em; text-decoration: none; font-weight: bold;}
  133. a.bluelink:active
  134. { color: 1A7DE8; font-family: arial; font-size: 1em; text-decoration: none; font-weight: bold;}
  135. a.bluelink:visited
  136. { color: 1A7DE8; font-family: arial; font-size: 1em; text-decoration: none; font-weight: bold;}
  137. a.bluelink:hover
  138. { color: 1A7DE8; font-family: arial; font-size: 1em; text-decoration: none; font-weight: bold;}

Last edited by Nico; 06-14-07 at 03:03 PM.
Reply With Quote
  #5 (permalink)  
Old 06-14-07, 04:08 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Wrap the top images in a <span> and set line-height to 0.

The footer needs to have the clear-attribute set (preferable to "both" or "left").
That will ensure that it stays clear of any floated elements on the page. That is, it doesn't place it self on the same "row" and instead jumps down to the next row of elements.

Take a look at http://www.positioniseverything.net/ or QuirksMode (link in my signature) for more info about all kinds of CSS quirks.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #6 (permalink)  
Old 06-15-07, 10:56 AM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
great, footer is fixed.

No luck with the images though...
Tried putting them in a span with zero: margin, padding and line-height but nothing

margin-top doesn't work in Firefox either?
And vertical-align doesn't seem to do anything either, for centering the white table heads on the right.
Reply With Quote
  #7 (permalink)  
Old 06-15-07, 03:13 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
The images look fine to me in both IE and FF.
Before, there was a visible gap between them (line-height) but now there's no visible gap, except for the white line which is part of the image of course...
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #8 (permalink)  
Old 06-16-07, 04:42 AM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah finally got it; i changed the strict doctype to transitional:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

I hope I'm not just "covering up" the defaults by lowering doctype standards?
Anyhow, both HTML and CSS turned out to be validated so I gues I shouldn't worry?
Reply With Quote
  #9 (permalink)  
Old 06-18-07, 07:28 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Transitional works fine, unless you really need strict (or want to show off your über skills as a web-programmer ) you don't have to use it.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #10 (permalink)  
Old 06-18-07, 01:37 PM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
I'm using strict now and it works with vertical-align: bottom;

No über skills here lol, not yet at least!!!!
Just trying to use open standards as much as I can.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
css drop down menu help! Space Cowboy CSS 2 01-10-07 12:36 AM
CSS Menu tobyjoiner CSS 3 12-11-06 01:45 PM
CSS - Menu Problem vivabensmith CSS 7 12-04-06 03:06 AM


All times are GMT -5. The time now is 02:03 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.