我是一名设计师/前端开发人员,但我必须将类为“span-4”的 div 移到类为“span-20”的 div 之前。编写 php 的开发人员无法询问如何不弄乱他的 php 标记。
预先感谢您的帮助!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>THRIVE</title>
<?php include("header.php"); ?>
</head>
<body>
<div class="container">
<div id="thumbnails" class="span-20 last">
<?php
$accessoriesDir = "images/accessories/";
$collectionCount = 1;
while(is_dir($accessoriesDir . $collectionCount . "/"))
{
$collection_dir = $accessoriesDir . $collectionCount . "/";
if ($season_dh = opendir($collection_dir))
{
$accsArray = array();
$accsCount = 0;
while (($accessoryFolder = readdir($season_dh)) !== false)
{
if(filetype($collection_dir . $accessoryFolder) == "dir" && strlen($accessoryFolder) > 2)
$accsArray[$accsCount++] = $accessoryFolder;
}
closedir($season_dh);
?>
<div id="collection<?php echo $collectionCount?>" class="thumbsHolder <?php if($collectionCount !== 1) echo 'hidden'?>">
<div class="cats span-4">
<?php
foreach($accsArray as $index => $accessory)
{
$class = "accessory-tab";
if($index == 0)
{
$class .= " selected";
}
echo "<a id='".strtolower($accessory)."-tab' class='".$class."'>".$accessory."</a><br/>";
}
?>
</div>
<?php
foreach($accsArray as $index => $accessory)
{
?>
<div id="<?php echo strtolower($accessory);?>-view" class="view <?php if($index != 0) echo 'hidden';?>">
<?php
$imageCount = 0;
$accessoryDir = $collection_dir.$accessory."/";
$dh = opendir($accessoryDir);
while (($file = readdir($dh)) !== false && $imageCount < 8)
{
if(filetype($accessoryDir . $file) == "file" && substr($file, -4) == ".jpg")
{
?>
<div class="thumbnailExpander <?php if($imageCount % 2 !== 0)echo 'expandLeft';?> <?php if($imageCount >= 4)echo 'bottom';?>"
style="left:<?php echo ($imageCount % 4) * (317-132) ?>px;top:<?php echo 110+((132+53)*intval($imageCount/4));?>px;">
<!--div class="thumbAnchor"-->
<img src="<?php echo $accessoryDir . $file ?>" style=""/>
<!--/div-->
</div>
<?php
$imageCount++;
}
}
?>
</div><!-- #accessory-view -->
<?php
closedir($dh);
}
?>
</div><!-- .thumbsHolder -->
<?php
}
$collectionCount++;
}
?>
</div><!-- #thumbnails -->
<?php include("nav.php"); ?>
<div id="debug" style="color:white"></div>
</div>
</body>
</html>
最佳答案
重构此代码以便首先显示 span-4 并不是一件容易的事。如果您没有 PHP 经验,这几乎是不可能的(也不建议)。
我建议您使用 CSS 在显示的页面上移动 span-4 元素。这样您就不需要接触 PHP。甚至更好;当 PHP 开发人员返回时,让他们重构此代码,以便显示代码不会与业务逻辑纠缠在一起(这是一种可怕的做法,使得此类问题无法回答)。
希望对一些人有帮助。
关于php - 尝试将一个 div 移到另一个 div 之前而不搞砸我不明白的 php :),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3990986/