您可以通过的langauge您在其中产生
您的网页,通过特定的字符串数字符串的lenght在一起,然后legth得到整个菜单的百分比计算的部分处理它。
这是计数
<?php
// percentageCounter.php
$menuItems = array(
'home'=>array('label'=>'Home'),
'learn'=>array('label'=>'Learn More About The Product',),
'about'=>array('label'=>'About Us',),
'contact'=>array('label'=>'Contact Us',),
'str_len_sum' => 0,
);
foreach($menuItems AS $key => $menuItem)
{
$menuItems['str_len_sum'] += strlen($menuItem['label']);
}
foreach($menuItems AS $key => $menuItem)
{
$menuItems[$key]['percentage'] = (100/$menuItems['str_len_sum'])*strlen($menuItem['label']);
}
剧本,这是打印菜单中的一个
<?php //menuOutput.php
require_once 'percentageCounter.php';
?>
<div id="parent">
<?php foreach($menuItems AS $key => $menuItem): ?>
<a href="/<?php echo $key ?>" style="width: <?php echo $menuItem['percentage'] ?>%;"><?php echo $menuItem['label'] ?></a>
<?php endif; ?>
</div>
我很努力想成为一个好人,不用表格来布局,但它一直在咬我! :) – JerSchneid 2009-08-26 15:23:55