Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php数组Pt.2最后一个元素的不同css样式_Php_Css_Arrays - Fatal编程技术网

php数组Pt.2最后一个元素的不同css样式

php数组Pt.2最后一个元素的不同css样式,php,css,arrays,Php,Css,Arrays,好的,这是我的新一期,也是我试图完成的一个完整的描述。我使用了您给我的建议,效果很好,但当我将“按信息排序”更改为其他字段和if语句时,它变得疯狂 这是我需要的,我在一个页面上有两列,当数组被处理时,我需要它显示从左到右从上到下填充每列的结果。每个项目之间都有一条分割线 <div class="centerBoxContentsFeatured centeredContent back vLine " style="width:50%;"> 每个项目下各一个 <div

好的,这是我的新一期,也是我试图完成的一个完整的描述。我使用了您给我的建议,效果很好,但当我将“按信息排序”更改为其他字段和if语句时,它变得疯狂

这是我需要的,我在一个页面上有两列,当数组被处理时,我需要它显示从左到右从上到下填充每列的结果。每个项目之间都有一条分割线

<div class="centerBoxContentsFeatured centeredContent back  vLine " style="width:50%;">

每个项目下各一个

<div class="product-col" >.  
如果项目是第3、第5、第7项等等……它将位于左侧,并且不需要在其前面添加“vLine”div,如果它是最后一个项目,则不需要“product col”它下面的div,因为最后两个项目不必有底部分隔符,但是如果整个页面上只有两个项目,底部分隔符可以保留。我做错了什么

<?php
$count_temp  = count ($productid);
for ($i = 0; $i < $count_temp; ++$i) {
    $artist = get_the_title();
    if (($productartist[$i] == $artist ) && $categoryID[$i] ==1 ) {
    ?>
//Content//
<?php if (!($i === 0) && !($i % 2)  &&
         ($productid[$i] == 1) &&
         ( $i === (count ($productid) - 1))) {
             echo'<div class="product-col-none" >';
      }
      else  { echo '<div class="product-col" >';} 
?>
//Content//
<? if !( $i === (count ($productid) - 1))
   { 
        echo '<div class="centerBoxContentsFeatured centeredContent back  vLine " '.
             'style="width:50%;">';
   }
   else { 
        echo '<div class="centerBoxContentsFeatured centeredContent back " '.
             'style="width:50%;">';}
?>

//内容//
//内容//

你应该在这里写你的css文件代码,你的html嵌入php代码让事情变得复杂和不清楚

如果您只想为编号为3,5,7..的奇数项目使用不同的样式,为最后一个项目使用不同的样式,那么我建议您使用
css伪类

您可以将css伪类last child用于最后一项

li:last-child
{
  // Your specific style for last item goes here
}
您还可以使用css伪类N子类(奇数)来交替使用奇数项

li:nth-child(odd)
{
  // Your specific style for odd items goes here
}

我希望这就是你想要的,当你可以在客户端设置完成的事情时,为什么要给服务器端加载呢。

你应该在这里写你的css文件代码,你的html嵌入php代码让事情变得复杂和不清楚

如果您只想为编号为3,5,7..的奇数项目使用不同的样式,为最后一个项目使用不同的样式,那么我建议您使用
css伪类

您可以将css伪类last child用于最后一项

li:last-child
{
  // Your specific style for last item goes here
}
您还可以使用css伪类N子类(奇数)来交替使用奇数项

li:nth-child(odd)
{
  // Your specific style for odd items goes here
}

我希望这就是您想要的,当您可以在客户端设置完成的事情时,为什么要给服务器端加载呢。

请提供一个指向您对应的另一个问题的链接。比如说“Pt.1”如果我的答案对你的问题有效,那么url会很好。你可以接受答案。请提供一个指向你对应的其他问题的链接。让我们说“Pt.1”…url会很好,如果我的答案对你的问题有效…你可以接受答案