Hi,
can someone please help me why those damn buttons are fleeing from my menu bar div?
The code below is full so it’s just to copy and paste.
[code=php]
<?php
class page {
private $buttons = array();
public $banner=”Test”;
public function Display()
{
echo “<html>n<head>n”;
$this -> ConfigureTopButtons();
$this -> DisplayStyles();
echo “</head>n<body>n”;
echo “<div id=”container”>”;
$this -> DisplayBanner();
$this -> DisplayTopMenu($this->buttons);
echo “</div>”;
echo “</body>n</html>n”;
}
private function ConfigureTopButtons() {
$buttons = array(
“Button 1” => “../Somelink1.php”,
“Button 2” => “../Somelink2.php”,
“Button 3” => “../Somelink3.php”,
“Button 4” => “../Somelink4.php”
);
$this->buttons= $buttons;
}
public function DisplayStyles()
{ ?>
<style>
body {
margin: 0; padding: 0;
text-align: center;
background-color:#ffffff;
}
#container {
background-color:#ffffff;
text-align:center;
height:auto;
width:80%;
min-width:800px;
position:relative;
top:0%;
margin:auto;
}
#banner {
background-image:<?php echo “url(“”.$this->classimagepath.$this->classtopimage.””)” ?>;
background-color:#ffffff;
height:10%;
width:100%;
position:relative;
float:left;
margin-top:0px;
margin-left:0px
}
#topmenu {
background-color:#123456;
height:30px;
width:100%;
position:relative;
float:left;
margin-top:0px;
margin-left:0px;
}
#tmitem {
display: inline-block;
background-color:#ff4321;
position:relative;
/* margin-top:0px;
margin-left:0px;*/
}
h1 {
font-family: arial, helvetica, sans-serif;
color: #000000;
font-size:40px;
text-align: left;
letter-spacing: -3px;
padding:0px;
margin-top:10px;
}
.clear {
clear: both;
}
.clearleft {
clear: left;
}
.inline {
display: inline-block;
margin:0px;
}
tm {
color:#ffffff; font-size:6pt; text-align:center;
font-family:arial,sans-serif
}
</style> <?php
}
public function DisplayBanner() {
echo “<div id=”banner”>”;
echo “<h1>”.$this->banner.”</h1>”;
echo “</div>” ;
}
public function DisplayTopMenu($buttons) {
echo “<div id=”topmenu”>”;
while (list($name, $url) = each($buttons)) {
$this -> DisplayNewTopButton($name, $url, !$this->IsURLCurrentPage($url));
}
echo “</div>”;
}
public function DisplayNewTopButton($caption, $url, $iscurrent) {
$b = new topmenubutton($caption, $url, $iscurrent);
$b ->display();
}
public function IsURLCurrentPage($url) {
if(strpos($_SERVER[‘PHP_SELF’], $url )==false) {
return false;
} else {
return true;
}
}
}
class topmenubutton {
private $width;
private $height;
private $caption;
private $url;
private $iscurrent;
public function __construct($caption, $url, $iscurrent){
$this->width = 100;
$this->height = 100;
$this->caption = $caption;
$this->url = $url;
$this->iscurrent=true;
}
public function display() {
echo ”
<a href=””.$this->url.””>
<div id=”tmitem” style=” width:”.$this->width.”px; height:”.$this->height.”%; “><tm>”.$this->caption.”</tm></div>
</a>”;
}
}
$a = new Page;
$a->display();
?>