“Ustaw lepkie CSS” Kod odpowiedzi

Ustaw lepkie CSS

/*
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

CSS Sticky NavigatioJn

nav {
	position:sticky;
	top:0;
}

/*Top can be replaced with bottom, left, or right 
	depending on what you want :) */
kadealicious

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

Odpowiedzi podobne do “Ustaw lepkie CSS”

Pytania podobne do “Ustaw lepkie CSS”

Więcej pokrewnych odpowiedzi na “Ustaw lepkie CSS” w CSS

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu