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.

nike air max tr 180 femme
Posts: 23
Comment
Genetic983
Reply #2 on : Sat April 13, 2019, 06:29:56
<a href="http://www.collegeksarsghir.com/es/scarpe-italia-2016-uomo-nike-air-max-tn-nere-royal-blu-bianche-miglior-prezzo">scarpe italia 2016 uomo nike air max tn nere royal blu bianche miglior prezzo</a><a href="http://www.collegeksarsghir.com/exclusive/mejores-zapatillas-running-nike-free-run-3-hombre-verde-zapatillas-de-correr">mejores zapatillas running nike free run 3 hombre verde zapatillas de correr</a><a href="http://www.collegeksarsghir.com/gazelle/adidas-pro-model-grey-white-gold-metallic-homme">adidas pro model grey white gold metallic homme</a><a href="http://www.collegeksarsghir.com/general/nike-mercurial-victory-vi-ic-fussballschuhe-gelb-silber-blau">nike mercurial victory vi ic fussballschuhe gelb silber blau</a>
[url=http://www.jobskidunya.com/general/nike-air-max-tr-180-femme]nike air max tr 180 femme[/url]
adidas tour 360 boost scarpe da golf uomo bianco white core black 46 eu
Posts: 23
Comment
Light46
Reply #1 on : Mon April 29, 2019, 07:50:21
<a href="http://www.dreamandcoaching.com/es/nike-air-foamposite-pro-yeezy-uomo">nike air foamposite pro yeezy uomo</a><a href="http://www.dreamandcoaching.com/exclusive/comprar-nike-air-max-1-desert-camo-baratas-espa%c3%b1a-outlet-online">comprar nike air max 1 desert camo baratas espa?a outlet online</a><a href="http://www.dreamandcoaching.com/gazelle/nike-kd-10-veterans-day-dames">nike kd 10 veterans day dames</a><a href="http://www.dreamandcoaching.com/general/nike-air-max-90-grey-sko">nike air max 90 grey sko</a>
[url=http://www.easysupplementalincome.com/2019/adidas-tour-360-boost-scarpe-da-golf-uomo-bianco-white-core-black-46-eu]adidas tour 360 boost scarpe da golf uomo bianco white core black 46 eu[/url]
First | Previous | Showing comments 21 to 22 of 22

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.