无论如何,是否可以在 div 中创建一个 div “突破”?父 div 的宽度而不指定子元素的宽度,仅指定子元素的宽度
即我有一个div,下面是一个隐藏的div,它比上面的div宽。我想指定内部的 div 具有比上面的 div 更大宽度的元素。这些元素的右侧与上面 div 的右侧对齐,但由于它更宽,因此希望左侧突出。下面的 div 与上面的 div 位于差异层上,因为它仅在单击上面的 div 的触发元素时出现。
基本上它是一个下拉列表,其中一些随机元素比上面的图像元素宽,单击时会删除该列表。但我希望下面的列表向左扩展,突破父 div,而不指定确切的位置。因此,这些元素都是父级 div 的子级,并与其右对齐,就像父级一样。
嗯嗯,希望你能关注。非常感谢任何帮助。提前致谢。
ie I have a div, below is a hidden div, which is wider than the div above. I want to specify the div inside to have elements with greater widths than the div above. these elements right hand side is aligned to the right hand side of the div above, but since it is wider, want the left hand side to break out. The div below is on a diff layer than the div above as it only appears on clicking on trigger element of div above.
Basically its a drop down list, with some random elements are wider than the image element above which, when clicked drops this list. but i want the list underneath to expand to the left breaking out of the parent div, without specifying exact positions. Therefore, the elements are all children of the parent div and right aligned to it, just like parent.
Hmmm, hope you can follow. Really appreciate any help. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
负利润率似乎是最好的答案。如果有人知道跨浏览器问题,请在这里发帖。也许我会但不会在一两周内对它们进行测试。
Negative Margins seems to be the best answer. If anyone knows of cross browser issues, please post here. Perhaps I will but shalln't be testing for them for a week or two.
您可能应该只使用选择标签(为了可访问性),即使它看起来不那么花哨。 添加你的 javascript 代码来隐藏/显示列表):
但如果你已经设置好了,请尝试这样的操作(并
如果你最终使用它,请将选项 div 更改为 ul 标记,将选项 div 更改为 li 标记,或者语义上更接近您正在构建的内容。在我的示例中,我只是使用 div 来减少 css 的数量。
You should probably just use a select tag (for accessibility's sake) even though it won't look as fancy. But if you're set on it, try something like this (and add your javascript code to hide/show the list):
and
If you end up using this, change the options div to a ul tag and the option divs to li tags, or something semantically closer to what you're building. I just used divs to cut down on the amount of css in my example.