使用 CSS 将背景图像设为较高 div 的高度
我的布局左侧是可变长度菜单,右侧是可变长度内容。菜单和内容之间是一个使用重复背景图像实现的分隔符,它是内容 div 的一部分。这意味着随着内容的扩展或收缩,分隔线也会扩展或收缩。
如果内容的高度小于菜单的高度,则分隔线仍然是内容的高度,而在这种情况下我真正想要的是分隔线是菜单的高度。有没有办法在CSS中实现这个?
I have a layout with a variable-length menu on the left, and variable-length content on the right. In between the menu and content is a divider implemented using a repeating background image, which is part of the content div. This means that as the content expands or contracts, so does the divider.
If the height of the content is less than the height of the menu, the divider is still the height of the content, when what I really want is the divider to be the height of the menu in this case. Is there any way to implement this in CSS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让内容和菜单中有分隔线背景图像,并使用负边距或类似的东西使内容区域与菜单重叠分隔线的宽度。
Have the dividers background image in the content are and the menu and have the content area overlap the menu the width of the divider using negative margins or something similar.
另一种方法是在包装 div 上使用背景图像,并使用背景位置将其放置在菜单和内容 div 之间。
An alternative would be to use the background image on a wrapper div and use background-position to place it between the menu and content divs.