Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 30-01-2006, 10:00 AM   #1
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

I've come across something odd. I got text and an image, and I want to align the text to the middle of the image (so that it comes at the middle height of the image), the image should be aligned left and the text centered. For some reason, this's harder than it sounds, as the img-tag's align attribute apparently can only take one parameter, which's either middle or left, but not both, nor's it take two allign attributes. Anybody know how I can still do this? Thanks in advance
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 30-01-2006, 11:08 AM   #2
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

Use css!

Code:
<html>
<head>
<style type="text/css">
img.middle {vertical-align:middle}
</style>
</head>

<body>
<p>
This is an 
<img class="top" border="0" 
src="logocss.gif" width="95" height="84" />
inside a paragraph with centered text.
</p>

</body></html>
Check out:
this example. If you change the code to the stuff above, you'll see the text aligned to the center of the image (or rather: the image is aligned to the text with its center).
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 30-01-2006, 11:39 AM   #3
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

I got that far, but we fixed it now. We set the image as a background image, aligned it left and set the repeat on no repeat. It works now, under Firefox. IE aligns the text at top, though.

Another thing I want to know, is if it's possible to make links target a div. Like if I have a menu div, and all choices need to load in the contents div. Is this even possible?
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 30-01-2006, 02:20 PM   #4
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

Double post :whistle: But woohoo! Found it Some CSS, using submit-buttons and readfile() does wonders
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 30-01-2006, 03:04 PM   #5
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

You can change the content of any HTML-element, so a <DIV> as well, through the DOM-model. This is kind of tricky, but with a little bit of patience can be done.

Check out: http://www.quirksmode.org/ for a very very indepth tutorial about that.
You could also use element.innerHTML to modify the contents. Quirksmode offers a comparison between the two ways as well. It's an excellent site.
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 30-01-2006, 04:28 PM   #6
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

I used submit-buttons, disguised as links through CSS (taking away their border, adding a hover-element... which doesn't work under IE, but does under Firefox), used a switch-statement to check for the value sent by those buttons and used readfile() accordingly to load a file into the div. 's That come close to the DOM model, or did I make one of my own?
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 30-01-2006, 06:01 PM   #7
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

Mmm... sounds weird But hey, if it works... On the other hand, if you had used DOM, it would have worked in most browsers...

Another good site: http://www.csszengarden.com/

Wicked CSS k:
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 30-01-2006, 07:31 PM   #8
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

Hehe, we've seen CSSZenGarden in class... in that one hour we've seen CSS. Good thing I'm good with self-study (especially during especially boring Dreamweaver classes :whistle: That and during exercise days), or that'd've been all I'd've seen of CSS I'll look into DOM tomorrow, though. We'll be done with the end exercise waaaaay too soon, anyways, so I'll have time with heaps (or so I think I will)
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 30-01-2006, 09:20 PM   #9
plix
Game freak

 
Join Date: Oct 2005
Location: ,
Posts: 113
Default

Quote:
Originally posted by Kon-Tiki@Jan 30 2006, 12:28 PM
I used submit-buttons, disguised as links through CSS (taking away their border, adding a hover-element... which doesn't work under IE, but does under Firefox), used a switch-statement to check for the value sent by those buttons and used readfile() accordingly to load a file into the div. 's That come close to the DOM model, or did I make one of my own? :D
I'm assuming that readfile() refers to PHP's readfile() function (the language really doesn't matter; I'm just taking it to mean server-side). As such, using a button rather than a link to do such a thing is rather bad form (especially if it's a POST rather than GET). PHP makes passing variables exceedingly easy and as such you probably should use something more along the lines of:
Code:
<all your html before the div>
<?php
$page = $_GET['page'];
if (is_file($page)
 * readfile($page);
else
 * readfile("an error page, or you could just echo an error message");
?>
<all your html after the div>
It's not pretty (the whole separation-of-presentation-from-logic ideology, etc) but you aren't trying to accomplish something terribly complex. If you use that example all your need to do is use links in the menu which contain page=thepagetoload in the query string (with a little preprocessing you can pretty that up a bit, but that's just an example, not a full-blown implementation).
plix is offline                         Send a private message to plix
Reply With Quote
Old 08-02-2006, 07:52 PM   #10
Mara
Abandonia nerd

 
Join Date: Jan 2006
Location: ,
Posts: 93
Default

http://www.w3.org/
html as it sould be used

stick to it to avoid problems like "works on ie and not on firefox"

-> the usefull thing is a html validator to check your pages Same goes for css.

then you can google for solution if nedeeed
Mara is offline                         Send a private message to Mara
Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Html Calendar Nick Programming 2 15-10-2006 07:54 AM
More Html Help Bobbin Threadbare Tech Corner 29 14-03-2006 02:33 PM
Html Scroll To: Bobbin Threadbare Tech Corner 2 28-02-2006 05:48 AM
Java/html - Two Questions ... swiss Programming 12 12-02-2006 10:57 AM
Html Problem punch999 Programming 6 16-12-2005 09:07 PM


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
Forum Jump
 


The current time is 08:15 PM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.