“CSS -Position klebrig” Code-Antworten

CSS -Position klebrig

/*
Try add this class to the element that you would like to make "sticky"
 - I hope it helps, happy coding ^_^
*/
.sticky{
  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 0; 
}
CoderHomie

Kleberoperationen in JavaScript

var siteHeader = document.getElementById('siteHeader'),
    siteNav = document.getElementById('siteNav');

    window.onscroll = function() {
        if ( siteNav.offsetTop < document.documentElement.scrollTop + 26 || siteNav.offsetTop < document.body.scrollTop + 26) {
            siteHeader.setAttribute("class","sticky");
        }
        else {
            siteHeader.setAttribute("class","");
        }
    }
Troubled Tortoise

Sticky Div

$(document).ready(function($){
	jQuery('.testimonials-slider-single').each(function(){
		var slider = jQuery(this);
		var arrowsHolder = slider.closest('.testimonials').find('.slider-nav');

		if (!slider.hasClass('slick-initialized')) {
			dots: false,
				slider.slick({
				prevArrow: '<button class="icon-prev slick-prev"></button>',
				nextArrow: '<button class="icon-next slick-next"></button>',
				arrows: true,
				slidesToShow: 1,
				slidesToScroll: 1,
				rows: 0,
				autoplay: true,
				appendArrows: arrowsHolder,
				adaptiveHeight: true
			});
		}
	});
	
	var $sticky = $('.res-article .cta-sec');
	var $stickyrStopper = $('.res-learning');
	if (!!$sticky.offset()) { // make sure ".sticky" element exists

		var generalSidebarHeight = $sticky.innerHeight();
		var stickyTop = $sticky.offset().top;
		var stickOffset = 100;
		var stickyStopperPosition = $stickyrStopper.offset().top;
		var stopPoint = stickyStopperPosition - generalSidebarHeight - stickOffset;
		var diff = stopPoint + stickOffset;

		$(window).scroll(function(){ // scroll event
			var windowTop = $(window).scrollTop(); // returns number

			if (stopPoint < windowTop) {
				$sticky.css({ position: 'absolute', top: diff });
			} else if (stickyTop < windowTop+stickOffset) {
				$sticky.css({ position: 'fixed', top: stickOffset });
			} else {
				$sticky.css({position: 'absolute', top: 'initial'});
			}
		});
	}
	
});
Perfect Peacock

Ähnliche Antworten wie “CSS -Position klebrig”

Fragen ähnlich wie “CSS -Position klebrig”

Weitere verwandte Antworten zu “CSS -Position klebrig” auf CSS

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen