小编Jan*_*nik的帖子

将 div 拉伸到全宽(如果有空间)

我目前正在研究 tumblr 主题,但卡在页面导航上。“上一个”和“下一个”按钮的 html 或仅呈现(如果可用)。所以第一页上没有下一个按钮,最后一页上没有上一个按钮。这就是我希望相应的单个按钮拉伸到 100% 宽度的地方。我可以在 javascript 中做到这一点,但它根本不是一个选项,因为模板也可以在没有 javascript 的情况下工作。

html 看起来像这样:

<div id="navigation">
<a href="#" id="prev" style="width:476px; float:left;" class="button_normal"><p>Prev</p></a>
<a href="#" id="next" style="width:476px; float:right;"class="button_normal"><p>Next</p></a>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.button_normal {
text-align: center;
opacity: 0.55;
height: 30px;
line-height: 30px;
background: white;
font-size: 13px;
font-weight: 100;
color: #646464;
border: 1px solid #646464;
text-decoration: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin-bottom: 10px;
}

#navigation{
clear: both;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)

父 div 的宽度是 960px,所以两个按钮之间应该有 8px 的边距。我尝试用 min-width 和 width: 100% auto 修复它;但无法真正弄清楚如何制作它。

提前致谢。

html css width css-float

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

css ×1

css-float ×1

html ×1

width ×1