dongmeng1875 2017-03-04 03:11
浏览 109
已采纳

备用行颜色UL LI

I'm trying to alternate row colors but instead only the bullet points are alternating colors at http://althedge.xyz Can someone show me how to do this? Thanks

I'm using this css code below to alternate the bullet point color but how to alternate the row color.

ul:nth-of-type(odd) {  
  color: #ccc;
}

Php file

<?php
// Database Settings 
define('DB_HOST', 'localhost');
define('DB_PORT', '*****');
define('DB_USER', '*****');
define('DB_PASS', '*****');
define('DB_NAME', '*****');

// Connection to Database
$database = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT);

$sql = 'SELECT * '
        . ' FROM crypto ORDER BY Date DESC, Number DESC';

$resultSet = $database->query($sql);

$currentDate = false;
while ($row = $resultSet->fetch_assoc()) {
    if ($row['Date'] != $currentDate) {
        echo $row['Date'] ;
        $currentDate = $row['Date'];  
    }

    echo '<ul><li>' . 
    '<A HREF="'.  
    $row["Link"].
    '"style="text-decoration: none;"'.
    '">'. 
    $row["Article"].
    '</A>'.
    '</li></ul>';
} 

$html .= '</table>';
echo $html;
?>
  • 写回答

5条回答 默认 最新

  • dongmufen8105 2017-03-04 03:31
    关注

    First, you should move the <ul> echo outside of the while loop. You only want a single <ul> element wrapping all of your <li>'s. That may honestly be intentional, but thought I should tell you nonetheless.

    Next up, your provided CSS is targeting the <ul> element itself, rather than the markup inside of them. And, finally, anchor elements have default styling in web browsers – that's why they're blue currently.

    ul li:nth-of-type(odd) a {
      color: #ccc;
    }
    <ul>
        <li>
            <a href="http://www.coindesk.com/ether-prices-surge-shadow-bitcoin-dash/" style="text-decoration: none;">dash bubble overshadows ethereum upswing...</a>
        </li>
        <li>
            <a href="https://www.reddit.com/r/ethtrader/comments/5xdcv8/asia_is_late_to_the_party_%E4%BA%9A%E6%B4%B2%E6%99%9A%E5%88%B0%E6%99%9A%E4%BC%9A/" style="text-decoration: none;">ethereum rises despite absent eth / cny markets...</a>
        </li>
        <li>
            <a href="https://news.vice.com/story/bitcoins-are-more-expensive-than-gold-now-thanks-china" style="text-decoration: none;">is the devalued yuan moving bitcoin...</a>
        </li>
        <li>
            <a href="http://fortune.com/2017/03/03/bitcoin-pricing-record/" style="text-decoration: none;">traders optimistic about the etf...</a>
        </li>
    </ul>

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启