So I have been looking into methods that would allow me to resize the left-margin on an element in my category-archive-display-page in accordance to the size of the thumbnail image that accompanies the element I want to work with (the element is an excerpt). I found out about using a .php file as a CSS sheet, and I am confused as to how to make it work. I made a .php file, and put the link to it in my archive.php file (which controls the display of the element). What I have so far in the .php file is this: <?php header("Content-type: text/css; charset: UTF-8"); echo "div.summary-content h2.posttitle, div.summary-content p.date, div.summary-content div.entry { margin-left:265px;}"; //$thumbnailx=get_the_post_thumbnail( $size[1] ); ?> PHP: The comment is what I will be using later on instead of 265, but now I am just looking for results. Is there something wrong with this code? Because there are definitely no results showing up on my website.
No, the CSS doesn't even show up if I view it in my browser (firefox). I don't even know if I'm writing correctly, or implementing it in the right way.
Even though this isn't relevent, I got an overview of HTML, CSS, and PHP at w3schools, Google it. It doesn't go into too much depth, but it's very simple.
Your header could be a problem depending upon the browser. Need more information (and you to test) to establish that. I recommend you try it in Firefox, Chrome, IE, Safari and Opera to ensure the CSS is displayed fine in all. Anyway, here's a short hand for what you could do: <?php header blah ?> whatever CSS <?php whatever PHP ?> Code (markup): Saves echoing/printing the CSS all of the time.
Oh, so I should just style it in the archive.php file without the external CSS sheet? I think I might have tried that already, but it won't hurt to try again.
I tried this... <style type="text/css"> div.summary-content h2.posttitle, div.summary-content p.date, div.summary-content div.entry { margin-left:<?php echo get_the_post_thumbnail( $size[1] ); ?>px; } </style> PHP: ...in the archive.php file with no results. When I change it to this... <style type="text/css"> div.summary-content h2.posttitle, div.summary-content p.date, div.summary-content div.entry { margin-left:265px; } </style> PHP: ...it puts the margin into the page. I am using the latest version of Firefox. Am I doing something wrong? PS: I think something got weird with the PHP tags, because they aren't displaying correctly (I think).
Try this for archive.php <?php header('content-type: text/css; charset: UTF-8'); header('cache-control: must-revalidate'); echo <<<'EOD' div.summary-content h2.posttitle, div.summary-content p.date, div.summary-content div.entry { margin-left:265px; } EOD; ?> PHP: And in the header use: <link rel="stylesheet" type="text/css" media="screen" href="/css-path/archive.php" />