我的网站上有一个 div,其中包含一个用作菜单的项目列表。我已经设置了 CSS width:auto
以便在菜单项太长时重新调整大小。不过目前,这会向右扩展并将我的其余内容也“推”到右边。
这很难解释,例如,如果您访问 http://redsquirrelsoftware.co.uk/ 并单击“支持”菜单项,您可以看到推送的内容。我想要发生的是让 div 扩展到菜单左侧的空白区域。
我目前为 div 使用的 CSS 是:
.sidebar1 {
float: left;
width: auto;
min-width: 25%;
max-width: 29%;
margin-top: 65px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border-radius: 12px;
}
有没有什么办法让它以另一种方式扩展?提前致谢。
原文由 crazyloonybin 发布,翻译遵循 CC BY-SA 4.0 许可协议
这个想法需要测试,但它至少在 Chrome 中有效:
.content
和.sidebar1
更改为float: right
而不是float: left
.content
.sidebar1
之后。