/    Sign up×
Community /Pin to ProfileBookmark

My divs are on the run. Please help.

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();

?>
[/code]

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@evoluerAug 29.2017 — Hello hybris,

Please send a link where the code is hosted. We can inspect the elements to know the exact reason
×

Success!

Help @hybris spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...