简体   繁体   English

将分页扩展到全宽吗?

[英]Extend pagination to full width?

How would one extend this pagination to be full width? 如何将这种分页扩展为全宽? I'm struggling. 我正在挣扎。

Example code: http://cssdeck.com/labs/cxdkfkjv 示例代码: http//cssdeck.com/labs/cxdkfkjv

Thanks 谢谢

This is the CSS code: 这是CSS代码:

 .pagination {
    text-align: justify;
    background: #f2f2f2;
    padding: 20px;
    margin-bottom: 20px;
}

    .page {
    display: inline-block;
    padding: 0px 9px;
    margin-right: 3px;
    border-radius: 3px;
    border: solid 1px #c0c0c0;
    background: #e9e9e9;
    box-shadow: inset 0px 1px 0px rgba(255,255,255, .8), 0px 1px 3px rgba(0,0,0, .1);
    font-size: .875em;
    font-weight: bold;
    text-decoration: none;
    color: #717171;
    text-shadow: 0px 1px 0px rgba(255,255,255, 1);
}

    .page:hover, .page.gradient:hover {
    background: #fefefe;
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FEFEFE), to(#f0f0f0));
    background: -moz-linear-gradient(0% 0% 270deg,#FEFEFE, #f0f0f0);
}

    .page.active {
    border: none;
    background: #616161;
    box-shadow: inset 0px 0px 8px rgba(0,0,0, .5), 0px 1px 0px rgba(255,255,255, .8);
    color: #f0f0f0;
    text-shadow: 0px 0px 3px rgba(0,0,0, .5);
}

    .page.gradient {
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f8f8f8), to(#e9e9e9));
    background: -moz-linear-gradient(0% 0% 270deg,#f8f8f8, #e9e9e9);
}

The HTML part comes in here HTML部分在这里

<div class="pagination">
    <p>How can I extend (justify) this pagination to the full width of the div "pagination"?</p>
    <a href="#" class="page gradient">first</a><a href=
    "#" class="page gradient">2</a><a href="#" class=
    "page gradient">3</a><span class=
    "page active">4</span><a href="#" class=
    "page gradient">5</a><a href="#" class=
    "page gradient">6</a><a href="#" class=
    "page gradient">last</a>
</div>

In your given markup, the child elements of pagination have no whitespace between them. 在给定的标记中,分页的子元素之间没有空格。

So firstly, make sure there is a whitespace in your markup between the child elements. 因此,首先,请确保子元素之间的标记中有空白。 Without this there's no way text-align:justify will work. 没有这个,就不可能text-align:justify起作用。

(Just like when you want to justify text, it won't work unless you have spaces between your words!) (就像您想证明文本的合理性一样,除非您的单词之间有空格,否则它将无法正常工作!)

Next, add a pseudo element after the pagination element with 100% width. 接下来,在分页元素后添加宽度为100%的伪元素。

Updated DEMO 更新了演示

..or for those who prefer a FIDDLE :) ..或适合喜欢FIDDLE的人 :)

.pagination:after
{
  content: '';
  width: 100%;
  display: inline-block;
}

Are you loocking for this ? 你loocking为这个

Set your .pagination to display: table; .pagination设置为display: table; and them your .page to table-cell . 然后将您的.page放到table-cell

Not sure what you want to do, if only center in the middle Anup just answered how to, but if you want to extend evenly all buttons, you can try and use display: table; 不确定要怎么做,如果只是中间的Anup回答了如何做,但是如果要均匀地扩展所有按钮,则可以尝试使用display:table;

http://cssdeck.com/labs/krdfmoeh http://cssdeck.com/labs/krdfmoeh

I'm not sure if there's an automatic way to do this. 我不确定是否有自动方法可以做到这一点。 What you could do is something like this: 您可以做的是这样的:

.pagination {
    text-align:center;
}

.page { 
    width:6%;
    margin:0 3.9%;
}

Remove the padding from .page or add * { box-sizing:border-box; 从.page删除填充或添加* {box-sizing:border-box; }. }。

If you want the first and left buttons to have to margin on the outside, give them "first" and "left" classes and do: 如果希望第一个和向左按钮必须在外部留出空白,请为它们提供“第一”和“左”类,然后执行以下操作:

.page {
    width:6%;
    margin:0 4.5%;
}

.page.first { margin-left:0; }
.page.last { margin-right:0; }

See: http://cssdeck.com/labs/yfuud0le 请参阅: http//cssdeck.com/labs/yfuud0le

Note that if you add more pagination items you have to manually edit the width and margin of the .page div. 请注意,如果添加更多分页项目,则必须手动编辑.page div的宽度和边距。

Center will look nice for you. 中心将为您看起来不错。

.pagination {
    text-align: center;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM