输出Div标签CSS样式不起作用

时间:2012-01-26 16:21:12

标签: css html styles stylesheet

好的,这就是发生了什么。使用Wordpress的Moneypress LE插件。能够通过Div标签“buynow”有效地输出html文件“CSL-products_class.php”作为立即购买按钮。问题是通过我附加的样式表关联的样式将无法加载。

您可以通过查看我的网站http://www.dustinschmidt.com上的源代码,同时检查其中一个产品来查看问题。 html是存在但没有风格。

添加了以下代码块:

$product_output[] = "<div class=\"{$this->css_prefix}-buynow\">";
        $product_output[] =
                "<a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-    sprocket-labs\">".'</a>';
        $product_output[] = '</div>';

以下是“CSL-products_class.php”的内容。

<?php


class wpCSL_products__mpcj {


function __construct($params) {

    // Properties with default values
    //
    $this->columns = 1;                 // How many columns/row in our display output.

    foreach ($params as $name => $value) {
        $this->$name = $value;
    }
 }

/*-------------------------------------
 * method: display_products
 *
 * Legacy Panhandler stuff that will eventually come out.
 * This method generates the HTML that will be used to display
 * the product list in WordPress when it renders the page.
 *
 */
function display_products($products) {
    $product_output[] = '';
    $moneyFormat = get_option($this->prefix.'-money_format');
    $linkModifiers = get_option($this->prefix.'-link_modifiers');
    $currCol = 0;        
    foreach ($products as $product) {

        // If we are on the first column, start a new row div
        //
        if ($currCol == 0) {
            $product_output[] = '<div class="'.$this->css_prefix.'-row">';
        }

        $product_output[] = "<div class=\"{$this->css_prefix}-product\">";
        $product_output[] = "<h3>{$product->name}</h3>";
        $product_output[] = "<div class=\"{$this->css_prefix}-left\">";
        $product_output[] = "<a href=\"{$product->web_urls[0]}\" target=\"cyber-sprocket-labs\" $linkModifiers>";
        $product_output[] = "<img src=\"{$product->image_urls[0]}\" alt=\"{$product->name}\" title=\"{$product->name}\" />";
        $product_output[] = '</a><br/>';
        $product_output[] = '<div class="'.$this->css_prefix.'-zoombox">';
        $product_output[] = '<a class="thickbox" href="'.$product->image_urls[0].'">&nbsp;</a>';
        $product_output[] = '</div>';
        $product_output[] = '</div>';
        $product_output[] = '<div class="'.$this->css_prefix . '-right">';
        $product_output[] = '<p class="' . $this->css_prefix . '-desc" >'.$product->description.'</p>';
        $product_output[] = '<p class="' . $this->css_prefix . '-price">'.$product->currency;
        if (function_exists('money_format') &&  ($moneyFormat != '')) {
            $product_output[] =
                "$ <a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-sprocket-labs\" $linkModifiers>".
                trim(money_format($moneyFormat, (float)$product->price)) .
                '</a>';
        } else {
            $product_output[] =
                "$ <a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-sprocket-labs\">".
                trim(number_format((float)$product->price, 2)) .
                '</a>';
        }
        $product_output[] = '</p>';
        $product_output[] = "<div class=\"{$this->css_prefix}-buynow\">";
        $product_output[] =
                "<a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-sprocket-labs\">".'</a>';
        $product_output[] = '</div>';

        $product_output[] = '</div>';
        $product_output[] = '<div class="'.$this->css_prefix.'-cleanup"></div>';            
        $product_output[] = '</div>';

        // Move to the next column, if we already hit the max desired
        // output columns, close the row and get ready for a new one
        //
        $currCol++;            
        if ($currCol == $this->columns) {
            $currCol = 0;
            $product_output[] = '</div>';
        }
    }

    // We did not end output on the last column
    // so we need to close the row div
    //
    if ($currCol > 0) {
        $currCol = 0;
        $product_output[] = '</div>';
    }

    return implode($product_output);
 }    


}

最后我的CSS为div标签“buynow”。

.csl_themes-buynow{background:url("../../core/images/buy-now.png") no-repeat;width:175px;height:64px;float:left}

感谢您的帮助, 多尘

1 个答案:

答案 0 :(得分:0)

通过转到http://www.dustinschmidt.com/watches/并查看源代码,我可以看到“csl_themes-buynow”类是几个div的引用。例如......

<div class="csl_themes-buynow"><a href="http://www.anrdoezrs.net/click-5462802-10535303?url=http%3A%2F%2Fwww.ashford.com%2Fashford%2Fbrowse%2FproductDetail.jsp%3FproductId%3D96B139%26source%3D406010001&cjsku=96B139" rel=nofollow target="cyber-sprocket-labs"></a></div>

因此,看起来CSS可能无法正确设置。

尝试在CSS上添加一个响亮的边框(类似于border: 10px solid limegreen)并查看它是否显示...