You might have seen websites that use html tables for displaying a long list of tabular information. While the information is nicely laid out it's sometimes difficult to read and follow especially when you have to scroll the page. To solve this problem, most designers will add alternating colors to the table rows using a technique called Zebra stripes.

Today, I'm going to show you how you can use Raxan PDI to add zebra stripes to your html tables

Let's say we have simple html page (my-web-page.html) with a table that looks like this:

FruitsSales (%) in Q3
Apple40
Mangoes20
Pears10
Grapes30
Banana25
Oranges45
Strawberries6

Toggle Code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Zebra Stripes</title>
    <link href="raxan/ui/css/master.css" rel="stylesheet" type="text/css" />
    <!--[if IE]><link rel="stylesheet" href="raxan/ui/css/master.ie.css"
    type="text/css"><![endif]-->
    <link href="raxan/ui/css/default/theme.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div class="container c35">
        <table class="border c25">
            <thead><tr class="tbl-header"><th>Fruits</th><th>Sales (%) in Q3</th></tr></thead>
            <tbody>
                <tr><td>Apple</td><td>40</td></tr>
                <tr><td>Mangoes</td><td>20</td></tr>
                <tr><td>Pears</td><td>10</td></tr>
                <tr><td>Grapes</td><td>30</td></tr>
                <tr><td>Banana</td><td>25</td></tr>
                <tr><td>Oranges</td><td>45</td></tr>
                <tr><td>Strawberries</td><td>6</td></tr>
            </tbody>
        </table>
    </div>
</body>

</html>

The first thing we need to do is to load our HTML page or view into the DOM. To do this, we will create a Rich Web page class called MyZebraStripes:


    <?php

    require_once("raxan/pdi/autosstart.php");

    class MyZebraStripes extends RaxanWebPage {
        protected function _init() {
            // load the html page
            $this->source('views/my-web-page.html');
        }
    }

    ?>

Next, we need to locate the even rows within the table. To do this, we will use the 'table tr:even' CSS selector:


    // find even table rows
    $rows = $this->find('table tr:even');

The above code will only select alternating <tr> elements within the table.

Finally, we need to add a CSS background color to the newly selected rows:


    $rows->css('background','#eee'); // add a background color

Here's what the entire code will look like:


    <?php

    require_once("raxan/pdi/autostart.php");

    class MyPage extends RaxanWebPage {

        protected function _init() {
            // load the html page
            $this->source('views/my-web-page.html');
        }

        protected function _load() {
            $rows = $this->find('table tr:even');
            $rows->css('background','#eee'); // add a background color
        }

    }
    ?>

There are many other things that you can do with Raxan Framework. Check out the full list of online examples.

air jordan 2 eminem edition for sale
Posts: 23
Comment
Access576
Reply #12 on : Sat January 12, 2019, 00:14:51
<a href="http://www.moroccolovesyou.com/en-us-shop/new-durable-black-yellow-nike-air-max-95-women-nike-air-max-running-shoe">new durable black yellow nike air max 95 women nike air max running shoe</a><a href="http://www.moroccolovesyou.com/factory-sale/black-purple-women-air-jordan-13-xiii">black purple women air jordan 13 xiii</a><a href="http://www.moroccolovesyou.com/fake/nike-free-flyknit-con-o-sin-calcetines">nike free flyknit con o sin calcetines</a><a href="http://www.moroccolovesyou.com/fashion-deals/nike-mercurialx-proximo-ii-df-tf-electric-green-black-ghost-green">nike mercurialx proximo ii df tf electric green black ghost green</a>
[url=http://www.herownblog.com/cheap-online/air-jordan-2-eminem-edition-for-sale]air jordan 2 eminem edition for sale[/url]
nike air max 1 essential hyper crimson
Posts: 23
Comment
Enterprise744
Reply #11 on : Wed March 20, 2019, 07:45:32
<a href="http://www.dellaise.com/good_review/wholesaler-nike-tennis-classic-ac-prm-triple-black">wholesaler nike tennis classic ac prm triple black</a><a href="http://www.dellaise.com/great-deals/nike-kobe-venomenon-6-black-white-men-basketball-shoes">nike kobe venomenon 6 black white men basketball shoes</a><a href="http://www.dellaise.com/hot_sale/nike-running-shoes-for-sale-online-fibreslystercom">nike running shoes for sale online fibreslystercom</a><a href="http://www.dellaise.com/on-sale/nike-air-max-2017-kpu-royal-blue-black-white-mens-898013-400">nike air max 2017 kpu royal blue black white mens 898013 400</a>
[url=http://www.dellaise.com/ca/nike-air-max-1-essential-hyper-crimson]nike air max 1 essential hyper crimson[/url]
nike air jordan retro 1 preschool schoenen
Posts: 23
Comment
Question708
Reply #10 on : Wed March 20, 2019, 21:08:13
<a href="http://www.jobskidunya.com/air_jordan/puma-leadcat-glitz-grade-school-girls-slide-m%c3%a6nd">puma leadcat glitz grade school girls slide m?nd</a><a href="http://www.jobskidunya.com/all_star/nike-damen-wmns-court-royale-turnschuhe">nike damen wmns court royale turnschuhe</a><a href="http://www.jobskidunya.com/asics/puma-suede-classic-herre">puma suede classic herre</a><a href="http://www.jobskidunya.com/a_bargain/nike-air-waffle-leather-sneaker-zapatillas-hombre-zapatillas">nike air waffle leather sneaker zapatillas hombre zapatillas</a>
[url=http://www.mckennaberghomes.com/blog/nike-air-jordan-retro-1-preschool-schoenen]nike air jordan retro 1 preschool schoenen[/url]
cheap nike dunk sky high womens blackish green and black white
Posts: 23
Comment
Marit727
Reply #9 on : Sun March 24, 2019, 08:53:39
<a href="http://www.knowitallbackground.com/Footwear/mens-air-max-nike-black-white-grey-new">mens air max nike black white grey new</a><a href="http://www.knowitallbackground.com/free-delivery/nike-pg2-x-playstation">nike pg2 x playstation</a><a href="http://www.knowitallbackground.com/hot-products/all-air-force-1-shoes">all air force 1 shoes</a><a href="http://www.knowitallbackground.com/instagram/fashion-sneakers-adidas-yeezy-boost-350-v2-cblack-red-footwear-black-red-boost-for-sale">fashion sneakers adidas yeezy boost 350 v2 cblack red footwear black red boost for sale</a>
[url=http://www.pulsemarketingbangor.com/on-sale/cheap-nike-dunk-sky-high-womens-blackish-green-and-black-white]cheap nike dunk sky high womens blackish green and black white[/url]
reebok transit zone
Posts: 23
Comment
Joystick777
Reply #8 on : Tue March 26, 2019, 17:14:24
<a href="http://www.chiczutphen.com/nz/cheap-nike-free-run-2-shoes-lunarglide-on-the-web">cheap nike free run 2 shoes lunarglide on the web</a><a href="http://www.chiczutphen.com/official_site/nike-air-flight-huarache-prm-quai-54">nike air flight huarache prm quai 54</a><a href="http://www.chiczutphen.com/on-feet/nike-air-max-90-lthr-iron-metallic-red-brown-sail-mens-womens-768887-201">nike air max 90 lthr iron metallic red brown sail mens womens 768887 201</a><a href="http://www.chiczutphen.com/uk/blue-red-men-air-jordan-3-shoes">blue red men air jordan 3 shoes</a>
[url=http://www.sparklingcarbonic.com/fake/reebok-transit-zone]reebok transit zone[/url]
zapatillas air max nostalgic midnight navy white black
Posts: 23
Comment
Tattoo37
Reply #7 on : Wed March 27, 2019, 01:17:50
<a href="http://www.kogian.com/us/chaussures-adidas-tubular-x-2-0-pearl-grey-w">chaussures adidas tubular x 2 0 pearl grey w</a><a href="http://www.kogian.com/vans/nike-free-powerlines-purper">nike free powerlines purper</a><a href="http://www.kogian.com/vapor/nike-air-force-1-low-travis-scott-sail-donna">nike air force 1 low travis scott sail donna</a><a href="http://www.kogian.com/yeezy/nike-lebron-12-elite-team-mujer">nike lebron 12 elite team mujer</a>
[url=http://www.barenboimencore.com/style/zapatillas-air-max-nostalgic-midnight-navy-white-black]zapatillas air max nostalgic midnight navy white black[/url]
new balance furon v4 dispatch in flame with aztec gold
Posts: 23
Comment
Parser626
Reply #6 on : Wed March 27, 2019, 18:32:36
<a href="http://www.getautoinsurancerate.com/shoes-sneakers/men-nike-air-jordan-11-future-black-blue-nike-huarache-rose-gold-nike">men nike air jordan 11 future black blue nike huarache rose gold nike</a><a href="http://www.getautoinsurancerate.com/shop-sale/air-jordan-13-3d-eyes-black-white-red">air jordan 13 3d eyes black white red</a><a href="http://www.getautoinsurancerate.com/sneakers-release/nike-jordan-1-flight-low-shoes-for-men-white-black-black">nike jordan 1 flight low shoes for men white black black</a><a href="http://www.getautoinsurancerate.com/tag/nike-air-max-90-womenss-shoes-wholesale-black-white-blue">nike air max 90 womenss shoes wholesale black white blue</a>
[url=http://www.hipnozistanfolyam.com/au/new-balance-furon-v4-dispatch-in-flame-with-aztec-gold]new balance furon v4 dispatch in flame with aztec gold[/url]
adidas adizero xt boost dam
Posts: 23
Comment
Genetic360
Reply #5 on : Thu March 28, 2019, 01:47:06
<a href="http://www.stonestreetantiques.com/core/nike-air-jordan-spiz-ike-gs-soar-black-schuhe-damen">nike air jordan spiz ike gs soar black schuhe damen</a><a href="http://www.stonestreetantiques.com/de/nike-air-presto-triple-black-gs-mujer">nike air presto triple black gs mujer</a><a href="http://www.stonestreetantiques.com/flyknit/nike-air-max-90-lx-beige-womens-02-schuhe-herren">nike air max 90 lx beige womens 02 schuhe herren</a><a href="http://www.stonestreetantiques.com/footwear/asics-gel-tech-walker-neo-4-schuhe-herren">asics gel tech walker neo 4 schuhe herren</a>
[url=http://www.barenboimencore.com/vente/adidas-adizero-xt-boost-dam]adidas adizero xt boost dam[/url]
nike lunar force 1 ns premium sko
Posts: 23
Comment
Yap359
Reply #4 on : Tue April 02, 2019, 13:06:36
<a href="http://www.zilvermine.com/a_wide_choice/chaussures-adidas-ultra-boost-uncaged-clear-grey-w">chaussures adidas ultra boost uncaged clear grey w</a><a href="http://www.zilvermine.com/blog/nike-lebron-14-mag-m%c4%99skie">nike lebron 14 mag m?skie</a><a href="http://www.zilvermine.com/classic/zapatillas-puma-sl-street-perf">zapatillas puma sl street perf</a><a href="http://www.zilvermine.com/collection/reebok-the-shroud-herre">reebok the shroud herre</a>
[url=http://www.virtual-pizza.com/available/nike-lunar-force-1-ns-premium-sko]nike lunar force 1 ns premium sko[/url]
nike tennis classic ultra leather red
Posts: 23
Comment
Griff460
Reply #3 on : Fri April 12, 2019, 16:49:35
<a href="http://www.dulichdathanh.com/uppkopplad/adidas-cf-advantage-raw-grey-blue-white-men-casual-shoes-sneakers-da9638">adidas cf advantage raw grey blue white men casual shoes sneakers da9638</a><a href="http://www.dulichdathanh.com/uusi/nike-kd-trey-5-v-ep-921540-010">nike kd trey 5 v ep 921540 010</a><a href="http://www.dulichdathanh.com/vrouw/adidas-neo-v-racer-2-0-black-white-grey-hombre">adidas neo v racer 2 0 black white grey hombre</a><a href="http://www.dulichdathanh.com/zni?ka/nike-air-max-97-ultra-17-buty-sportowe-m%c4%99skie-42-5">nike air max 97 ultra 17 buty sportowe m?skie 42 5</a>
[url=http://www.theaterkey.com/good_review/nike-tennis-classic-ultra-leather-red]nike tennis classic ultra leather red[/url]
First | Previous | Showing comments 11 to 20 of 22 | Next | Last

Leave a Comment

Required fields are marked with *.
If you have trouble reading the code, click on the code itself to generate a new random code.