在布局中不显眼地插入垂直分隔线
我想插入一个灰色的垂直分隔线,将两侧均匀分开以显示逻辑划分。由于两侧内容的高度可能会根据用户选择的内容而变化,因此分隔线需要适当缩放 - 换句话说,不能是固定高度。
顺便说一句,理想情况下,我可以有条件地插入和删除该样式元素。显然某种 div 可以提供最大化控制。
这是我现有的 HTML/CSS 代码:
I want to insert a grey vertical divider that splits the two sides evenly to show a logical division. Since the content on the two sides can vary in height depending on what the user selects, the divider needs to scale appropriately -- in other words, can't be fixed height.
As an aside, ideally this style element would be something that I could conditionally insert and remove. Obviously some sort of div would give maximize control.
Here's my existing HTML/CSS code:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不会插入元素,而是将两侧设计为等高的列。在左侧使用 border-right,或在右侧使用 border-left,以显示划分。
有关等高列的指南,请参阅:CSS - 等高列?。
Rather than inserting an element, I'd look at styling the two sides as equal-height columns. Use a border-right on the left side, or border-left on the right, to show the division.
See: CSS - Equal Height Columns? for guidance on equal-height columns.
将
border-left: 2px Solid grey
或border-right: 2px Solid grey
应用于其中一列怎么样?How about you apply
border-left: 2px solid gray
orborder-right: 2px solid gray
to one of the columns?