以下代码没有问题,我只需要添加内联样式
<div id="nav-menu" style="width:65px;">
。我需要你的帮助来包括那种风格。
<?php
$pages = array('health.php' => 'Health',
'weightloss.php' => 'Weight Loss',
'fitness.php' => 'Fitness',
'sex.php' => 'Sex',
'mindbody.php' => 'Mind-Body',
'food.php' => 'Food',
'beauty.php' => 'Beauty',
'more.php' => 'More');
echo "<div id=\"nav-menu\">\n";
// let's create a unordered list to display the items
echo "<ul>";
// here's where all the items get printed
foreach ($pages as $Listing) {
echo "<li>$Listing</li>\n";
}
// closing the unordered list
echo "</ul>";
echo "</div>\n";
?>
答案 0 :(得分:4)
你是说这个吗?
echo "<div id=\"nav-menu\" style=\"width:65px;\">\n";
OR
echo "<div id='nav-menu' style='width:65px;'>\n";
OR
echo '<div id="nav-menu" style="width:65px;">' . "\n";
答案 1 :(得分:0)
echo "<div id=\"nav-menu\" style=\"width:65px;\">\n";
答案 2 :(得分:0)
echo '<div id="nav-menu" style="width:65px;">';
答案 3 :(得分:-1)
默认情况下,您无法为<div>
等块元素设置宽度;它占据了容器的整个宽度。
尝试:echo "<div id=\"nav-menu\" style=\"width:65px;display:inline-block;\">\n";