简体   繁体   English

如何使用ant-design在布局中拉伸父元素宽度

[英]How to stretch parent element width in layout with ant-design

Demo here.演示在这里。

<div style={{width: 2000, background: 'red'}}>content</div>

The parent div is not affected by the child width, maybe because it's flex?父 div 不受子宽度的影响,也许是因为它是 flex? Then how should I set the parent width according to its child's width?那么我应该如何根据其孩子的宽度设置父宽度?

You can set align-items: flex-start to the parent container (the default value stretch causes the Content width to be restricted ):您可以将align-items: flex-start设置为父容器(默认值拉伸会导致Content宽度受到限制):

<Layout className="layout" style={{ padding: '0 24px 24px' }}>
    <Breadcrumb style={{ margin: '12px 0' }}>
      <Breadcrumb.Item>Home</Breadcrumb.Item>
      <Breadcrumb.Item>List</Breadcrumb.Item>
      <Breadcrumb.Item>App</Breadcrumb.Item>
    </Breadcrumb>
    <Content style={{background: '#fff', padding: 24, margin: 0, minHeight: 280}}>
      <div style={{width: 2000, background: 'red'}}>content</div>
    </Content>
</Layout>

with style:风格:

.layout {
  align-items: flex-start;
}

See updated codepen .请参阅updated codepen

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 ant-design 步骤滚动到特定的 id 组件 - How to scroll to particular id component using ant-design steps 如何使元素( <a>)拉伸到其父元素(容器)的整个宽度?</a> - How to make an element (<a>) stretch to the full width of its parent element (container)? 将元素拉伸到填充流体母体的整个宽度 - Stretch element to full width of a padded fluid parent 如何在 ant-design 选择的 v-decorator 中使用条件 if else 语句 - how to use conditional if else statement in v-decorator of an ant-design selection 如何覆盖 ant-design cechkbox 以使用 font-awesome 图标? - How to override ant-design cechkbox to use font-awesome icon? 在未知宽度的父级内部沿着固定宽度的元素拉伸未知宽度的元素 - Stretch an element of unknown width alongside elements of fixed width inside parent of unknown width 如何使body元素的宽度延伸到html的宽度? - How to make width of body element stretch to the width of html? 用父级的宽度和高度拉伸 iframe - Stretch an iframe with width and height of parent 如何拉伸 h1 容器以匹配父 div 的 100% 宽度 - how to stretch h1 container to match 100% width of parent div 如何将织物画布拉伸到其父 div 的全宽 - How to stretch a fabric canvas to the full width of its parent div
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM