GithubHelp home page GithubHelp logo

zepto.pin.js's Introduction

zepto.pin.js

Ever wanted to pin something to the side of a text? Ever needed a subtle sticky element to quietly hang around as you scroll down? Zepto.Pin is here to help! Pin any element to the top of a container. Easily disable it for smaller screen-sizes where there's no room for that kind of shenanigans.

##Usage

Include zepto and zepto pin at the bottom of your html. Then pin any element you want like this:

$(".pinned").pin();

To make a pinned element stay within an outer container, use the containerSelector option:

$(".pinned").pin({containerSelector: ".container"});

Padding can also be added around the pinned element while scrolling:

$(".pinned").pin({padding: {top: 10, bottom: 10}});

That's it - go pin all the things!

##用法

钉住指定元素在body容器

$(".pinned").pin();

钉住指定元素在指定父元素容器

 $(".pinned").pin({containerSelector: ".container"})

设置被钉住元素的在容器内的偏移量

$(".pinned").pin({padding: {top: 10, bottom: 10}});

钉住效果产生时可以动态添加样式

$(".pinned").pin({activeClass: "className"}});

zepto.pin.js's People

Contributors

jingchaofang avatar

Stargazers

 avatar Ma Ming avatar

Watchers

James Cloos avatar Ma Ming avatar  avatar

Forkers

isdom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.