简体   繁体   English

div块转到Firefox中的下一行

[英]div block going to next line in Firefox

I have a div with display:block in my css. 我的CSS中有一个display:block的div。 This div block uses the align = "absmiddle" . 该div块使用align = "absmiddle" It displays all the elements in 1 line in Chrome. 它在Chrome中以1行显示所有元素。 However, in firefox, the elements are displyed on to the next line as well. 但是,在Firefox中,这些元素也会显示在下一行上。 How do I get them to display in 1 single line in firefox. 我如何让它们在firefox中以1行显示。

PS: I have already tried display: inline but it does not bring it in 1 line. PS:我已经尝试过display: inline但是它并没有把它放在1行中。

<div class="one"><input name="elementone" value="1" align="absmiddle" class="subone" /></div>

Css is CSS是

div.one,div.subone{
display:block; 
width:16px; 
height:100%;
background-position:0 0px;
border:0
}

I'm a little unclear on what you're trying to accomplish - centering input elements in a div? 对于您要完成的工作,我还不太清楚-将div中的输入元素居中?

All you need is a text-align: center on container div that holds all the inputs [.one is the class that should have center text alignment in the case of your example html]. 您需要做的只是一个文本对齐:位于容器div的中心,该容器容纳所有输入[在示例html的情况下,.one是应具有中心文本对齐的类。

Note there are some issues with your css 请注意,您的CSS存在一些问题

div.one,div.subone{ /*div.subone refers to a div with the class subone - not an input like you have*/
display:block; /*divs are already block elements */
width:16px;  /* may be the issue, why restrict the width? */
height:100%; /*basically meaningless */
background-position:0 0px; /*default*/
border:0
}

***Note: generally when you are trying to wrap a bunch of inline elements like inputs each inside their own div, there is another way to skin that cat. ***注意:通常,当您尝试将一堆内联元素(如输入)包装在各自的div中时,还有另一种方法可以使猫变皮。 For instance, in this case if you have a number of divs with the class .one - they will show up on their own line because your css requires each div to display block. 例如,在这种情况下,如果您有多个.one类的div-它们将显示在自己的行上,因为您的CSS要求每个div都显示块。

I don't really understand your question but if you want multiple <div class="one"> in one line just float them left or right. 我不太了解您的问题,但是如果您想在一行中包含多个<div class="one"> ,只需向左或向右浮动即可。 However they will still jump to second line once the container div width is exceded. 但是,一旦超出容器div的宽度,它们仍将跳至第二行。 You could try and use a combination of white-space and overflow on the parent div. 您可以尝试在父div上使用空格和溢出的组合。

But as I say - your problem is quite unclear from the question. 但正如我所说-您的问题尚不清楚。

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

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