Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

center pagination? #304

Closed
edsu opened this issue Sep 25, 2011 · 9 comments
Closed

center pagination? #304

edsu opened this issue Sep 25, 2011 · 9 comments

Comments

@edsu
Copy link

edsu commented Sep 25, 2011

Is there a known and preferred way to center the pagination div?

@lvivier
Copy link

lvivier commented Sep 26, 2011

Try something like this?

.pagination.center,
.pagination.center ul {
    float: left;
    position: relative;
}
.pagination.center { left: 50%; }
.pagination.center ul { left: -50%; }

and then

<div class="pagination center"></div>

@edsu
Copy link
Author

edsu commented Sep 26, 2011

that worked perfectly, thanks so much!

@edsu edsu closed this as completed Sep 26, 2011
@jasny
Copy link
Contributor

jasny commented Nov 15, 2011

Instead of using relative positioning, you can also do

.pagination ul {
   float: none;
   display: inline-block;
   overflow: hidden;
}
.pagination.center {
   text-align: center;
}

I think this is preferable. In fact, I've put in a pull request #638 :)

@kevva
Copy link
Contributor

kevva commented Nov 15, 2011

A little more cross browser friendly.

.pagination {
    word-spacing: -1em; /* hide whitespace between elements if separated by whitespace in the source */
    text-align:center;
}
.pagination li {
    display: -moz-inline-box; /* FF2 or lower */
    display: inline-block;
    word-spacing: normal;
    vertical-align: top;
    /* IE6/7 inline-block hack */
    *display: inline;
    *zoom: 1;
}

http://jsfiddle.net/KGN4A/1/

@jasny
Copy link
Contributor

jasny commented Nov 15, 2011

Thank kevva. However, don't you mean .pagination ul instead of .pagination li :)

@kevva
Copy link
Contributor

kevva commented Nov 15, 2011

Nope. Have a look at the example.

@jasny
Copy link
Contributor

jasny commented Nov 15, 2011

@kevva Unfortunately your demo is not how the pagination element works in bootstrap. First of all .pagination is the <div> and not the <ul>.

The .pagination ul is still floating left. Setting .pagination ul { float: none; }, makes it span over the full width, which looks different than the original.

See http://jsfiddle.net/hMR4r/

It's needed to display .pagination ul as inline-block. You can leave .pagination li unchanged. This also means that you don't have to do word-spacing: -1em;

This works better: http://jsfiddle.net/mJvKC/

However I think my previous version will do, since it only have to work for FF4+ / IE7+, not for older browsers.

@kevva
Copy link
Contributor

kevva commented Nov 16, 2011

@jasny, yeah, you're right. You won't need overflow hidden though, but inline-block hack is needed for IE7.

.pagination.center {
  text-align: center;
}
.pagination ul {
  display: -moz-inline-box; /* FF2 or lower */
  display: inline-block;
  /* IE6/7 inline-block hack */
  *display: inline;
  *zoom: 1;
}

http://jsfiddle.net/KGN4A/11/

daveobriencouk pushed a commit to egocreative/bootstrap that referenced this issue Nov 18, 2012
@jasny jasny mentioned this issue Jun 3, 2013
@nokah1988
Copy link

thanks for sharing this little code

@twbs twbs locked and limited conversation to collaborators Jun 22, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants