douw92892 2014-06-01 16:46
浏览 42

使用<a>元素使整个块可单击

I want that the whole block be possible to click when hover the cursor over, to click on a link to go the link.

Example:

How this now:

The code of the component is:

<li<?php echo strlen($item->custom_tags) ? ' class="'.$item->custom_tags.'"' : ''; ?> data-mosaic-item>
<div class="sprocket-mosaic-item" data-mosaic-content>
    <?php echo $item->custom_ordering_items; ?>
    <div class="sprocket-padding">
        <?php if ($item->getPrimaryImage()) :?>
        <div class="sprocket-mosaic-image-container">
            <?php if ($item->getPrimaryLink()) : ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
            <img src="<?php echo $item->getPrimaryImage()->getSource(); ?>" alt="" class="sprocket-mosaic-image" />
            <?php if ($item->getPrimaryLink()) : ?>
                <span class="sprocket-mosaic-hover"></span>
                <span class="sprocket-mosaic-hovercontent"><span>+</span><?php rc_e('READ_MORE'); ?></span>
            </a>
            <?php endif; ?>

        <?php if ($item->getPrimaryLink()) : ?>
            <a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="sprocket-readmore"><span><?php rc_e('READ_MORE'); ?></span></a>
        <?php endif; ?>


        <?php if (count($item->custom_tags_list)) : ?>
            <ul class="sprocket-mosaic-tags">
            <?php
                foreach($item->custom_tags_list as $key => $name){
                    echo ' <li class="sprocket-tags-'.$key.'">'.$name.'</li>';
                }
            ?>
            </ul>
        <?php endif; ?>

        </div>
        <?php endif; ?>

        <div class="sprocket-mosaic-head">
            <?php if ($item->getTitle()): ?>
            <h2 class="sprocket-mosaic-title">
                <?php if ($item->getPrimaryLink()): ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
                    <?php echo $item->getTitle();?>
                <?php if ($item->getPrimaryLink()): ?></a><?php endif; ?>
            </h2>
            <?php endif; ?>

            <?php if ($parameters->get('mosaic_article_details')): ?>
            <div class="sprocket-mosaic-infos">
                <span class="author"><?php //echo $item->getAuthor(); ?></span>

                <!-- 
                <i class="icon-time"></i> 
                <span class="mosaic-date">
                    <?php //echo $item->getDate();?>
                </span> -->

                <?php if($item->getDate()): ?>
                <!-- Date created -->
                <span class="mosaic-date">
                    <i class="icon-time"></i>
                    <?php echo JHTML::_('date', $item->getDate(), JText::_('d M Y')); ?>
                </span>
                <?php endif; ?>


            </div>

            <?php endif; ?>



        </div>




        <div class="sprocket-mosaic-text">
            <?php echo $item->getText(); ?>
        </div>

    </div>
</div>

So i want the entire block of red border to be possible to click

  • 写回答

2条回答 默认 最新

  • du1843 2014-06-01 16:52
    关注

    My english is not the best, so I hope that I got you right:

    you want one div-container to be clickable?

    if that is what you want, why don't you wrap the div container by your link

    Code Example:

    <a href="...">
    <div>
    //Additional Code in here
    </div>
    </a>
    
    评论

报告相同问题?