锚点在不同页面上的边缘顶部

时间:2017-10-19 10:05:28

标签: javascript php jquery html css

我在主页上有一个链接到其他页面的锚点。

目前菜单在标题上,我看不到文字,我想添加一个空格/边距。位置太靠近顶部,我想在顶部添加一个空间以创建菜单距离。 感谢

主页上的

链接:

<ul class = "activityLink" style="margin-left:-10px;"><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#public-relations"  class = "activityLink" ">

第二页:

<div class="activityhead">
<div class="container"><h1><?php echo get_the_title(); ?></h1></div
</div>
<div class="clearfix"></div>
<div class="container">
<?php
$AvitiyTypes = get_terms(array(
    'taxonomy' => 'activtyType',
    'hide_empty' => true,
        )
);

if (is_array($AvitiyTypes) && !empty($AvitiyTypes)) {
    $totalActivity = sizeof($AvitiyTypes);
    $ctr = 0;
    foreach ($AvitiyTypes as $AvitiyType) {
        $ctr++;
        $lastDivClass = '';
        if ($ctr == $totalActivity) {
            $lastDivClass = 'b0';
        }
        ?>
        <div id="<?php echo $AvitiyType->slug; ?>" class="activsect  <?php echo $lastDivClass; ?>">
            <h2><?php print_r($AvitiyType->name); ?></h2>
            <div class="row" style="margin-top:54px;">
                <?php
                $args = array(
                    'post_type' => array('activity'),
                    'post_status' => array('publish'),
                    'tax_query' => array(
                        'relation' => 'AND',
                        array(
                            'taxonomy' => 'activtyType',
                            'field' => 'slug',
                            'terms' => array($AvitiyType->slug),
                            'include_children' => true,
                            'operator' => 'IN'
                        )
                    ),
                );
                $activities = new WP_Query($args);

                if ($activities->posts) {
                    $activities = $activities->posts;
                    if (is_array($activities) && !empty($activities)) {
                        ?>
                        <!-- qui vanno le sottocategorie -->
                        <div class="col-sm-3">
                            <ul style="list-style:disc;">

                                    <!--<li><a href="javascript:void(0)" class="activity_post_title" data-post="<?php echo $activity->ID; ?>" data-taxonomy="<?php echo $AvitiyType->term_id; ?>"><?php echo $activity->work_area; ?></a></li>-->
                                    <ul style="list-style:disc; margin-left:30px;">

                                                   <!-- <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" class = "activityLink"><?php echo $activity->work_home;  ?>dru</a></li>-->
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Eventi</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Roadshow</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Incentive</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Advertising</a></li>


                                            </ul>
                                              <ul style="list-style:disc; margin-left:30px;">

                                                   <!-- <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" class = "activityLink"><?php echo $activity->work_home;  ?>dru</a></li>-->
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Media Relations</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Networking</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Convegni-Seminari</a></li>


                                            </ul>
                                              <ul style="list-style:disc; margin-left:30px;">

                                                   <!-- <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" class = "activityLink"><?php echo $activity->work_home;  ?>dru</a></li>-->
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Bilanci</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Report sostenibilità</a></li>
                                                    <li><a href = "<?php echo get_permalink(get_page_by_path('activity-page')); ?>#<?php echo $AvitiyType->slug;?>" >Report ambientali</a></li>


                                            </ul>

                            </ul>
                        </div>
                        <div class="col-sm-9">
                            <div id="taxonomy_description_<?php echo $AvitiyType->term_id; ?>" class="description_<?php echo $AvitiyType->term_id; ?>">
                                <?php 
                                echo wpautop(term_description( $AvitiyType->term_id, 'activtyType' ));
                                //echo wpautop($AvitiyType->description); 
                                ?>
                                <div class="clearfix viewgallery1"><a href="<?php echo get_post_type_archive_link('activity'); ?>?cat=<?php echo $AvitiyType->slug; ?>">VAI ALLA GALLERY &gt;</a></div>
                            </div>
                            <?php
                            foreach ($activities as $activity) {
                                ?>
                                <div id="post_description_<?php echo $activity->ID; ?>" class="description_<?php echo $AvitiyType->term_id; ?>" style="display: none;">
                                    <?php echo wpautop($activity->post_content); ?>
                                    <div class="clearfix viewgallery1">
                                        <a href="<?php echo get_post_type_archive_link('activity'); ?>?cat=<?php echo $AvitiyType->slug; ?>&data=<?php echo $activity->post_name; ?>">VAI ALLA GALLERY &gt;</a>
                                    </div>
                                </div>
                                <?php
                            }
                            ?>
                        </div>
                        <?php
                    }
                }
                ?>
            </div>
        </div>
        <div class="clearfix"></div>
        <?php
    }
}
?>

实际上我在第二页有这个js

    jQuery(document).ready(function () {
    jQuery('.activity_post_title').click(function () {
        taxonomy_id = jQuery(this).attr('data-taxonomy');
        post_id = jQuery(this).attr('data-post');

        jQuery('.description_' + taxonomy_id).hide();
        jQuery('#post_description_' + post_id).show();
    });

    jQuery('.atta a').css('color', '#b07988').addClass('dru');
});

0 个答案:

没有答案