在绝对定位的元素上向左浮动
我试图实现一种效果,其中多个绝对定位的元素在向左浮动时会表现出来。我试图避免使用类或第 n 个子选择器,因为绝对定位的 div 数量是动态的。
所以div宽度是800px,我想让所有div向左浮动,但现在它们彼此堆叠,我不知道如何使div 1 left: 0, div 2 left:800, div剩下 3 个:1600 等,不使用类或第 n 个子选择器。这可以使用 jQuery 甚至 css 实现吗?
谢谢你!
I'm trying to achive an effect where severeal absolutely positioned elements would behave as they were being floated to the left. I'm trying to avoid using classes or nth-child selectors because the number of divs being absolutely positioned is dynamic.
So the div width is 800px and I'd like to have all divs floated to the left, but now they are stacked over eachother and I don't know how to make div 1 be left: 0, div 2 left:800, div 3 left: 1600 and so on without using classes or nth-child selectors. Is this possible using jQuery or maybe even css?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多方法......
jQuery:
你可以相对定位你的div然后浮动它们。
但是在 jQuery 中,您必须有一个具有所有 div 宽度的包装器:
您能否详细介绍一下您的结构(DOM、CSS 等)。
这有助于为您的需求制定最佳解决方案......
There are many ways....
jQuery:
You can position your divs relative and then float them.
But you will have to have a wrapper with the width off all divs, in jQuery:
Can you please tell more about your structure (DOM, css, etc).
This helps to make the best solution for your needs...