Return to Snippet

Revision: 5302
at March 3, 2008 03:44 by nijgnet


Updated Code
/*
 * Applies pseudo-pseudo classes to inline list items.
 * Mainly used for autogenerated subnavs.
 * 
 * @param $the_list String: html code of <li> elements
 * @param $first Bool: apply style to the first <li>
 * @param $last Bool: apply style to the last <li>
 * @return $the_list String: modified html code
 */
function remove_padding_li ($the_list, $first=FALSE, $last=FALSE)
{
    if ($first) {
        $the_list = preg_replace('/^<li class=\"/i', '<li class="first ', $the_list);
    }
    if ($last) {
        $the_list = preg_replace('/<li class=\"(.*)$/i', '<li class="last $1', $the_list);
    }
    return $the_list;
}

Revision: 5301
at February 25, 2008 14:52 by nijgnet


Initial Code
/*
 * Applies pseudo-pseudo classes to inline list items.
 * Mainly used for autogenerated subnavs.
 * 
 * @param $the_list String: html code of <li> elements
 * @param $first Bool: apply style to the first <li>
 * @param $last Bool: apply style to the last <li>
 * @return $the_list String: modified html code
 */
function remove_padding_li ($the_list, $first=FALSE, $last=FALSE)
{
    $the_list = preg_replace('/^<li class=\"/i', '<li class="first ', $the_list);
    $the_list = preg_replace('/<li class=\"(.*)$/i', '<li class="last $1', $the_list);
    return $the_list;
}

Initial URL


Initial Description
Inserts "first" and "last" classes to the first and last  items respectively. "first" and "last" classes defined in CSS as without padding.

Initial Title
Remove leftmost and rightmost padding in LI output

Initial Tags
css, wordpress

Initial Language
PHP