Jump to content

[SOLVED] css within if statement


asloan

Recommended Posts

Sorry I wasn't sure if I was suppose to start a new thread or not but here we go...

 

I'm checking to see if it's the homepage and if it is the homepage I would like the css to change.  but it is not working....any ideas?

 

if (!$_SERVER['QUERY_STRING']) {

    echo('<style type="text/css"><!--#page_bg {padding: 0;background: #000;} div.center { text-align: center; margin: 10px auto 0 auto; padding: 0; width: 900px; background: #ffffff url(../images/content_top.jpg) top center no-repeat--></style>');

 

}

 

thank you,

Andrea

 

if (!$_SERVER['QUERY_STRING']) {

    echo('<style type="text/css"><!--#page_bg {padding: 0;background: #000;} div.center { text-align: center; margin: 10px auto 0 auto; padding: 0; width: 900px; background: #ffffff url(../images/content_top.jpg) top center no-repeat--></style>');

 

}

Link to comment
https://forums.phpfreaks.com/topic/139704-solved-css-within-if-statement/
Share on other sites

You are placing it in the wrong place.  I checked out your site and you are printing the style block at the very top of the page.  You need to print the style block at the bottom of the <head> block.

 

It looks like you are using Joomla, so you will have to dig around in the templates to find out where it is. 

 

Here is the HTML for your web page.  I added a comment where you need to put your new styles.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="robots" content="index, follow" />
  <meta name="keywords" content="joomla, Joomla" />
  <meta name="description" content="Joomla! - the dynamic portal engine and content management system" />
  <meta name="generator" content="Joomla! 1.5 - Open Source Content Management" />
  <title>Benedictine College School of Business</title>

  <link href="/index.php?format=feed&type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />
  <link href="/index.php?format=feed&type=atom" rel="alternate" type="application/atom+xml" title="Atom 1.0" />
  <link href="/templates/siteground-j15-48/favicon.ico" rel="shortcut icon" type="image/x-icon" />
  <script type="text/javascript" src="/media/system/js/mootools.js"></script>
  <script type="text/javascript" src="/media/system/js/caption.js"></script>


<link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="/templates/siteground-j15-48/css/template.css" type="text/css" />

<!-- YOU NEED YOUR HOMEPAGE SPECIFIC STYLES TO GO HERE -->
<?php if (!$_SERVER['QUERY_STRING']): ?>
<style type="text/css">
#page_bg {
    padding: 0;
    background: #000;
} 
div.center {   
    text-align: center;   
    margin: 10px auto 0 auto;   
    padding: 0;   
    width: 900px;   
    background: #ffffff url(../images/content_top.jpg) top center no-repeat
}
</style>
<?php endif; ?>

</head>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.