Jump to content

after including css not centered anymore


scherpenzeel

Recommended Posts

Hi I have this site were i use a page system like ?action=page1 etc.To get this working i have an index.php where i include a page called navigation.That holds the part that ensures the ?action=... The pages i have designed with css style sheet are nice looking and centred in the middle where I want it to be. But after the include in the index page they are no longer centred and are. on the left site.Now I tried to include the css part in the index page again ?which works but than I have two <head></head> parts in the page which is not good... :)How can I solve this problem. It also apears whem just using the navigation page as index.php ....Any idear. you can have a look here for sample page:just type index.php and you wil see what the difference is.My Webpagelooking forward to sharp idears.

Link to comment
Share on other sites

when using include you do not need to use <html> and <head>, etc tags in the include file.Here is an exampleindex.php

<html><head><title>...</title><link rel="stylesheet" type="text/css" href="url"/></head><body><!--navigation--><div><?php include('include_file.php');?></div><div>some content.....</div></body></html>

include_file.php

<table>  <tr>    <td><a href="index.php?action=page1">Page 1</a></td>    <td><a href="index.php?action=page2">Page 2</a></td>    <td><a href="index.php?action=page3">Page 3</a></td>  </tr></table>

Link to comment
Share on other sites

Thanks for your quick reaction. Ok I had that already in mind as a possible solution. Now I wil give it a try. So all important tags need to be on the index.php ? But what if someone find a page which is indexed by google? Than it has no title? Or Am i wrong here. Well lets see how things are working, hopefully the css wil do its job then..:)Thanks

Link to comment
Share on other sites

Google will not index your include files unless you make direct links to them on your webpages. Also you could disallow bots access to your includes folder with the robots.txt file.

Link to comment
Share on other sites

Hi I have tried your solution, now the page wil be included without the html parts but the css is still messed up???  Aaaaaaaaah, (sorry). here is the same problem occuring on a other site I am working on:the messed up ones My Webpagelike it should show (for now its only good in IE, for FF must change soemthings?):the right page

<?phpsession_start();ob_start();error_reporting(E_ALL);//Alles includen wat we nodig hebben.//Controlleer of iemand ingelogd is of een koekje heeft om dat te regelen.//controlleerinlog();//Controlleer of iemand hier wel welkom is.//controlleerban(); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>WWW.MENES.NL MEUBELMAKERIJ NIJMEGEN KEUKENS TAFELS KASTEN EN INTERIEURBOUW ALLES OP MAAT</title><script language="JavaScript" src="inhoud/javascript.js"></script><link href="/css/menes_details.css" rel="stylesheet" type="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"></head><body onLoad="thisForm=document.formulier;"><?php// toegestane pagina's in een array zetten$toegestaan=array("home","voorbeelden","werkwijze","contact","nieuws","aanbieding","keukencheck","keukendetail","registreren","mail","activeren","inloggen","uitloggen","fotoboek","fotoalbum");// controleren of er een pagina is meegegeven)if(isset($_GET['actie'])){	// de binnengehaalde variabele omzetten naar kleine letters	$actie = strtolower($_GET['actie']);	// controleren of de pagina voorkomt in de array	if (in_array($actie, $toegestaan))	{   	 // wanneer die toegestaan is includen   	 include($actie.".php");    }else{   	 // wanneer die niet toegestaan is standaard pagina includen.   	 include("home.php");    }}else{	include("home.php");}?> </body></html>

pages are included by ?action=page.phpNow whem just opening the page directly like www.sitename/page.phpThey look realy fine. But when including in above system they are completely messed up????? What can I do please help.Thanks.

Link to comment
Share on other sites

1. Is the CSS not functioning at all, or just now how you intended it to function? If it's not working at all, most likely you have some error in your reference to the CSS, although I'm not sure how including the file would cause this.2. Check your included file for any unclosed tags - these are the most likely thing that would hurt your CSS formatting3. Are you using any CSS that selects elements by order? I'm not even sure if you can do that in CSS2 or not, but including the other file might offset the order of certain elementsThe best way to check your CSS for errors is to put debugging info in, like giving all your <table> and <div> tags 3px wide red borders and setting a different background color for your main CSS classes, that should show you alot of information about what's going on.

Link to comment
Share on other sites

1. Is the CSS not functioning at all, or just now how you intended it to function? If it's not working at all, most likely you have some error in your reference to the CSS, although I'm not sure how including the file would cause this.2. Check your included file for any unclosed tags - these are the most likely thing that would hurt your CSS formatting3. Are you using any CSS that selects elements by order? I'm not even sure if you can do that in CSS2 or not, but including the other file might offset the order of certain elementsThe best way to check your CSS for errors is to put debugging info in, like giving all your <table> and <div> tags 3px wide red borders and setting a different background color for your main CSS classes, that should show you alot of information about what's going on.

this is the page i include:
<div id="wrapper"><div id="container"><!-- logo --><!-- div id="logo"></div> --><!-- navigatie --><div id="navigatie"><?php include("topmenu.php");?></div><!-- 8 boxes --><div id="sub_home"><div id="kop_in_plaatsvan_submenu">Onze werkwijze</div>  <div id="boxes_homepage"><ul><li class="meubels"><a href="?actie=voorbeelden"></a></li><li class="tafel"><a href="?actie=voorbeelden"></a></li><li class="check"><a href="?actie=voorbeelden"></a></li><li class="keuken1"><a href="?actie=voorbeelden"></a></li><li class="balie"><a href="?actie=voorbeelden"></a></li><li class="bedrijf"><a href="?actie=voorbeelden"></a></li><li class="keuken2"><a href="?actie=voorbeelden"></a></li><li class="keukens"><a href="?actie=voorbeelden"></a></li></ul></div></div></div></div></div></div>

nothing special I gues? I can post my css as well.. :)

Link to comment
Share on other sites

also if your CSS is missing a [;] between attributes it will cause CSS havoc (nothing will work)

Actually, that is a very good point. An error in your CSS code will still result in the document being parsed up until the point of the error, after which everything else will be ignored. Maybe this is the cause of your difficulties?
Link to comment
Share on other sites

Actually, that is a very good point. An error in your CSS code will still result in the document being parsed up until the point of the error, after which everything else will be ignored. Maybe this is the cause of your difficulties?

OK thanks for the good hints I will have a closer look at the css. For the menu I include topmenu.php which looks like this:
<ul id="nav"><li><a href="?actie=home">Home</a></li><li><a href="?actie=voorbeelden">Voorbeelden</a></li><li><a href="?actie=werkwijze">Werkwijze </a></li><li><a href="?actie=aanbiedingen">Aanbiedingen</a></li><li><a href="?actie=contact">Contact</a></li></ul>

Can this cause any problems. Or is it necessary that all the line are "echo-ed" ?Have this as well in a other site and works well for that one. Strange thing is that the other site I meantioned above looks good in both iE en FF but is only in IE not centered? http://mokasol.nl in this site i use the same system as above..:) with include and the menu included as well.

Link to comment
Share on other sites

If you aren't sure about problems with the output when you are doing includes, then look at the source that gets generated and figure out where the problem is there. Then you can backtrack from where the problem appears to where it comes from.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...