FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

PHP imagecreate + CSS problem.

 


Diablosblizz
Now that I've moved from web to other coding languages, I've come across Vista's sidebar and how to make gadgets for them. I am having a problem though. I am making a apache + mysql pinger for my server, it's working well but I can't align the image to the top corner. See an example here:

http://clan-ik.frih.net/bserver/test.html

It's right in the top corner, no margin. I am having trouble doing that in PHP, and I am not quite sure if this is a PHP problem, or a CSS problem. Here's what I have so far:

Code:
<style>
body {
margin: 0;
}
</style>
<body>
<?php
$my_img = imagecreate( 199, 50 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, "TEXT",
  $text_colour );
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );

header( "Content-type: image/png" );
imagepng( $my_img );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
?>
</body>


It just gives me some stupid header errors, and I know that you can't do it from CSS when you're creating an image with PHP, which leaves me in quite a problem here. Basically, I NEED this to be aligned right to the corner, else it will look off centered and will have a white background.

Does anybody have a work around for this? Or is there a way to set the margin before creating the image with PHP?

Thank you for your help.
AftershockVibe
If the body is containing the image shouldn't you be setting it's padding property rather than (or as well as) the margin?
Cool



edit: Errr... this is ignoring the whole image creation within the page issue. Why can't you just add/remove the padding yourself within the imagecreate() functions?
Diablosblizz
That's what I am trying to ask, how to do it with imagecreate, or something similar. Unfortunately, according to the PHP website imagecreate only takes two parameters, width and height.
riccopt
use 2 different files... one to create the image and another to do the align

for example: you will call the image.php file like this on the index.html:
<img src="img.php">

and then you set everything you want on the CSS file


(even if I was not really able to fully understand your question)
Diablosblizz
Nice! I never though of that! I have another problem now, I found a way to have a transparent background, but now I get a weird coloured text.

As seen here:



Code:

Code:
<g:background id="canvas" src="images/canvas.png" style="position: absolute; height: 70px; width: 130px; top: 0px; left: 0px; z-index: -999;" opacity="0" />
<font color="Black">Test</font>
riccopt
Diablosblizz wrote:
Nice! I never though of that! I have another problem now, I found a way to have a transparent background, but now I get a weird coloured text.

As seen here:



Code:

Code:
<g:background id="canvas" src="images/canvas.png" style="position: absolute; height: 70px; width: 130px; top: 0px; left: 0px; z-index: -999;" opacity="0" />
<font color="Black">Test</font>

it looks like the BG image is on TOP of the text...

on this image I generate (calling the php file here)
[img]http://mysweetebony.com/geo/webmaster.php[/img]

I use an image to the BG and the white text on top of it...
riccopt
Diablosblizz wrote:
Nice! I never though of that! I have another problem now, I found a way to have a transparent background, but now I get a weird coloured text.

As seen here:



Code:

Code:
<g:background id="canvas" src="images/canvas.png" style="position: absolute; height: 70px; width: 130px; top: 0px; left: 0px; z-index: -999;" opacity="0" />
<font color="Black">Test</font>

it looks like the BG image is on TOP of the text...

on this image I generate (calling the php file here)
[img]http://mysweetebony.com/geo/webmaster.php[/img]

I use an image to the BG and the white text on top of it...
Diablosblizz
That doesn't help, but I figured it out. Thanks.
riccopt
Diablosblizz wrote:
That doesn't help, but I figured it out. Thanks.

I was going to say that without seeing all the code that generates the image it would be a bit hard to help you out...
Related topics

PHP imagecreate + CSS problem.
What do you use to make your page layout?
CSS problem...
PHP include code problem
PHP homepage recreation problem

Runaway CSS Header - Need to find a way to scale it
CSS Problem
Problem with PHP
Css problem
PHP Form Sending problem

Probably a minor CSS issue
Php while array problem
CSS problem in IE 6
PHP login script problem
Slight css problem in IE [SOLVED]
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.