npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery-make-me-center

v1.0.0

Published

A jQuery plugin to position elements vertically and horizontally center with support Margin and Padding

Downloads

4

Readme

jQuery Make Me Center

A jQuery plugin to position elements vertically and horizontally center relative to windows or some other element. Not only you can center the element on page but you can also add Margin and Padding to your element and that plugin will take care of it and will keep your element always center vertically and horizontally.

Lets take an example we have popup contact form and we want to keep it center that's ok but we have one problem that we want to add some padding and margin to that Popup Contact Form on Mobile devices so it will not stuck to the window. To achieve this we usually take some more inner div containers and add padding and margin to inner containers in order to keep popup positioned perfectly always. But using this plugin you can add margin and padding to the same element instead of inner elements and it will always be in center position.

Installation

  • Include jquery.makemecenter.js after the main jquery js files

Options

  • position absolute|fixed|static
    • Sepecify that element position default value: absolute
  • horizontal true|false
    • Sepecify that element should be horizontally center or not default value: true
  • vertical true|false
    • Sepecify that element should be vertical center or not default value: true
  • parentRelative window
    • Sepecify parent element to which parent element will take as relative default value: windows
  • complete
    • User can specify cusotm callaback on complete
  • marginLeft
    • Define Margin from Left on element default value: 0
  • marginRight
    • Define Margin from Right on element default value: 0
  • marginTop
    • Define Margin from Top on element default value: 0
  • paddingLeft
    • Define Margin from Left on element default value: 0
  • paddingRight
    • Define Margin from Right on element default value: 0
  • paddingTop
    • Define Margin from Top on element default value: 0
  • paddingBottom
    • Define Margin from Bottom on element default value: 0
  • is_onload
    • Center Element on Page Load default value: true
  • is_onresize
    • Center Element on Resize default value: true
  • is_animate
    • Animate Element while Centering it default value: false

Some Usage

To make element center vertically and horizontally simple use

$("div.box").makemecenter();

All options at a glance

$("div.box").makemecenter({
		position : "absolute",
		horizontal : true,
		vertical : true,
		parentRelative : window,  // Define Parent against which elements needs to be centered
		complete : null,
		
		marginLeft : null,
		marginRight : null,
		marginTop : null,
		paddingLeft : null,
		paddingRight : null,
		paddingTop : null,
		paddingBottom : null,

		is_onload : true,    // Center Element on Page Load
		is_onresize : true,  // Center Element on Resize
		is_animate : false,  // Animate Element while Centering it
});

Check out some examples

Go to the plugins web page to check out a number of examples on usage. the plugins web page