Difference between revisions of "Template:BNU-CHINA/article"
Line 12: | Line 12: | ||
} | } | ||
</style> | </style> | ||
+ | |||
+ | <script> | ||
+ | $("article h2").each(function (index, item) { | ||
+ | $("ul.sub-nav").prepend($("<li>").append( | ||
+ | $("<a>").addClass("btn-filter btn") | ||
+ | .attr("data-tartget", index) | ||
+ | .text($(item).text()) | ||
+ | )); | ||
+ | }); | ||
+ | |||
+ | $("ul.sub-nav a").click(function () { | ||
+ | console.log($("article h2")[$(this).attr("data-tartget")]); | ||
+ | $("html, body").animate({scrollTop: $($("article h2")[$(this).attr("data-tartget")]).offset().top - $(".sub-header").height()}, "slow"); | ||
+ | }); | ||
+ | |||
+ | $(document).scroll(function (event) { | ||
+ | if (($(window).scrollTop() <= $(".navbar-siren").height())) { | ||
+ | $(".sub-header").css({ | ||
+ | "transform": "translate3D(0, -100%, 0)", | ||
+ | }); | ||
+ | } else { | ||
+ | $(".sub-header").css({ | ||
+ | "transform": "translate3D(0, 0, 0)", | ||
+ | }); | ||
+ | } | ||
+ | }); | ||
+ | </script> | ||
<div class="content container"> | <div class="content container"> |
Revision as of 19:55, 17 September 2015