0

我一直在尝试研究如何将链接包裹在 div 容器周围,以便可以使产品列表框成为产品信息页面的链接。我尝试过使用主页上显示的特价商品,但无济于事。

这是代码

 $list_box_contents = array();
while (!$specials_index->EOF) {
$products_price = zen_get_products_display_price($specials_index->fields['products_id']);

$products_description = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($specials_index->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); //To Display Product Desc 

$products_description = ltrim(substr($products_description, 0, 39) . '...'); //Trims and Limits the desc

if (!isset($productsInCategory[$specials_index->fields['products_id']])) $productsInCategory[$specials_index->fields['products_id']] = zen_get_generated_category_path_rev($specials_index->fields['master_categories_id']);

$specials_index->fields['products_name'] = zen_get_products_name($specials_index->fields['products_id']);
$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsSpecials centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($specials_index->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '   <div class="imagename"><div class="product_image">
<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $specials_index->fields['products_image'], $specials_index->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div><div class="product_name">') . '<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . $specials_index->fields['products_id']) . '">' . $specials_index->fields['products_name'] . '</a></div><div class="product_desc"><p class="s_desc">' . $products_description .'</p></div></div><div class="propricemain"><div class="prodprice">' . $products_price . '</div><div class="productbtn"><div class="mj-productdetailimage"><a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']) . '">More</a></div></div></div>');

我很高兴使用 css 或 jquery 来完成此任务。

4

1 回答 1

0

用链接包装一个 div 听起来你想要完成这个:

<a href="product-page">
<div>
    Product information
</div>

虽然这可能适用于大多数浏览器,但它是非法的(语义不正确),因为链接不应包装 div。

我个人的选择包括向 div 添加 onclick 行为,可能看起来像这样:

<div style="cursor: pointer;" onclick="window.location='http://product-page';">
Product Information goes here.
</div>

如果您仍想“用链接包装”,您可以更改您的 for a .

于 2013-10-23T16:51:41.877 回答