简体   繁体   English

CSS中的多个位置选择器

[英]Multiple Position Selectors in CSS

I have multiple Div's that I am using as buttons. 我有多个Div用作按钮。 If I set the postition to relative I can use float left to put them all on one row next to eachother. 如果我将位置设置为相对,则可以使用左移将它们全部放在彼此相邻的一行上。 They also appear at the top of the parent div. 它们也显示在父div的顶部。 I want the buttons to appear at the bottom of the parent div. 我希望按钮显示在父div的底部。 Is it possible to give an element two position values as in 是否可以给元素两个位置值,如

position: relative;
float: left;

and also 并且

position: absolute;
bottom: 0;

I have a feeling this is a logic error of some kind and I am not sure how to do this logic. 我感觉这是某种逻辑错误,我不确定如何执行此逻辑。

just put them into wrapper 放进包装纸

<style>div.buttons{position:absolute;bottom:0;}</style>
<div class="buttons">...</div>

if float is problem, use display:inline-block; 如果浮动是问题,请使用display:inline-block; for positioning add position:relative to the parent div, and use position:absolute to child divs. 对于定位,请添加position:relative对于父div,并使用position:absolute到子div。

Please note with display inline-block you need to extra hack for IE7 *display:inline (if you are still supporting it), and if you see white space btw buttons, refer 请注意,对于display inline-block,您需要对IE7 *display:inline进行额外修改(如果您仍在支持的话),并且如果看到空格btw按钮, 请参阅

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

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