“Posisikan CSS Sticky” Kode Jawaban

Posisikan CSS Sticky

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

Div Sticky

$(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

Jawaban yang mirip dengan “Posisikan CSS Sticky”

Pertanyaan yang mirip dengan “Posisikan CSS Sticky”

Lebih banyak jawaban terkait untuk “Posisikan CSS Sticky” di CSS

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya