kleur anders na include

Status
Niet open voor verdere reacties.

schorrie01

Gebruiker
Lid geworden
7 aug 2006
Berichten
79
Ik maakte een topsection.php, een main3.php en een test.php

topsection.php staat een div met background color

main3.php heeft een andere background color

wanneer ik beide in test.php via een include in een document zet, krijg ik wel de twee balken, maar beide in dezelfde kleur,

hij pakt dus automatisch de kleur van de div welke laatst werd ingevoegd via include,

hoe kan ik dit oplossen, zodat div's een aparte kleur krijgen
 
Laatst bewerkt:
Aangezien je gaan includen moet je geen dubbele HTML, HEAD en BODY tags gebruiken...

Daarnaast is het logisch dat je nu een gelijke kleur hebt. Je overschrijft immers de CSS id Layer1

Dit is je broncode nu:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<div id="header"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Layer1 {
	width:100%;
	height:125px;
	left: 0;
	top: 0;
	background-color: #999933;
}
-->
</style>

</head>

<body>
<div id="Layer1"></div>
</body>
</html>
</div>
<div id="main"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Layer1 {
	width:100%;
	height:125px;
	left: 0;
	top: 0;
	background-color: #0000FF;
}
-->
</style>
</head>

<body>
<div id="Layer1">DIT IS DE MAIN </div>
</body>
</html>
</div>
<div id="footer"></div>
</body>
</html>

Zo wil je het hebben.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
#header{
	width:100%;
	height:125px;
	left: 0;
	top: 0;
	background-color: #999933;
}

#main {
	width:100%;
	height:125px;
	left: 0;
	top: 0;
	background-color: #0000FF;
}
</style>
</head>

<body>
<div id="header">DIT IS JE HEADER</div>
<div id="main">DIT IS DE MAIN </div>
<div id="footer">DIT IS JE FOOTER</div>
</body>
</html>
Dan is het erg makkelijk om te maken.

index.php
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
#header{
	width:100%;
	height:125px;
	left: 0;
	top: 0;
	background-color: #999933;
}

#main {
	width:100%;
	height:125px;
	left: 0;
	top: 0;
	background-color: #0000FF;
}
</style>
</head>

<body>
<div id="header">
 <?php include('header.php'); ?>
</div>
<div id="main">
 <?php include('main.php'); ?>
</div>
<div id="footer">
 <?php include('footer.php');
</div>
</body>
</html>
header.php
PHP:
<?php
$getal = 0;
$getal++;

echo 'Dit is je '. $getal .'e header';
?>
main.php
PHP:
<?php
echo 'Dit is je main';
?>
footer.php
PHP:
<?php
echo 'Dit is je footer';
?>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan