【问题标题】:How to add tr:nth-child inside tag table?如何在标签表中添加 tr:nth-child?
【发布时间】:2018-10-02 12:45:18
【问题描述】:

内容我的控制器:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class AutoLoadDiv extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this->load->view('ngoding/AutoLoad');
    }

    public function getData() {

        $this->load->library('table');
        $err = file_get_contents("application\logs\log.php");
        $filestr = preg_replace(array('/(^|\R)ERROR\s*-\s*/', '/(^|\R)(.*?)\s*-->\s*/'), array('$1', '$1$2 '), $err);
        $arraySpacing = nl2br($filestr);
        $arr = explode("\n", $arraySpacing);

        $output = '<table style="tr:nth-child(even){background-color#FFF;} tr:nth-child(odd){background-color:#CCC;}", border="1px solid #dddddd;" >'; 
        for ($i = count($arr)-1; $i >= 0; $i--) {
            $output.="<tr><td>$arr[$i]</td></tr>"; 
        }
        $output.="</table>"; 
        echo $output; 


        }
    }

我有问题添加颜色背景每一行是不同的行,我找到了我的答案但没有工作,答案是在tr:nth-child(even)tr:nth-child(odd)中添加代码,如何在标签中添加tr:nth-child(even)tr:nth-child(odd) ?

【问题讨论】:

  • 无法在控制器中添加标签
  • ok 谢谢你,现在工作
  • 你的评论不能投票
  • 为什么我要举报你的评论,你的评论没有违反

标签: php html css codeigniter


【解决方案1】:

添加另一个包含样式表的$output,就像:

$output = '<style> tr:nth-child(even){background-color#FFF;} tr:nth-child(odd){background-color:#CCC;} </style>';
$output .= '<table border="1px solid #dddddd;" >'; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-30
    • 2010-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-08
    • 1970-01-01
    相关资源
    最近更新 更多