简体   繁体   English

角度材料 - 为什么我的md按钮全宽?

[英]Angular Material - Why is my md-button full-width?

Simple issue, I've made a really basic page to play around with Angular Material. 简单的问题,我已经制作了一个非常基本的页面来使用Angular Material。 I have a button which is visible on medium-sized devices which toggles the side navigation, and for some reason it is full width. 我有一个在中型设备上可见的按钮,可以切换侧面导航,由于某种原因,它是全宽的。 There is no CSS which is making it full width, and there are no Material directives which are making it full width. 没有CSS使其成为全宽度,并且没有使其成为全宽度的Material指令。 It seems to have inherited the width of the container it's in, but I can't see why. 它似乎继承了它所在容器的宽度,但我不明白为什么。

Can anyone with a bit of Angular Material knowledge see why? 任何有一点Angular Material知识的人都可以看到原因吗? (Just resize the window pane to see the button) (只需调整窗口大小以查看按钮)

Here's my CodePen: 这是我的CodePen:

http://codepen.io/anon/pen/jPYNzy http://codepen.io/anon/pen/jPYNzy

And the code: 和代码:

<!-- Container -->
<div layout="column" layout-fill>
    <div layout="row" flex>

        <!-- Content -->
        <md-content flex>

            <md-toolbar>
                <div class="md-toolbar-tools">
                    <h1>Title</h1>
                </div>
            </md-toolbar>

            <div layout="column" class="md-padding">
                <p>
                The left sidenav will 'lock open' on a medium (>=960px wide) device.
                </p>
                <md-button ng-click="toggleLeft()" hide-gt-md>
                    Toggle left
                </md-button>
            </div>

        </md-content><!-- ./Content -->

    </div>
</div><!-- ./Container -->

Just wrap it in another div if this is undesired. 如果这是不希望的, 只需将它包装在另一个div The flex-direction of <div layout="column"> seems to be responsible for the behavior. <div layout="column">的flex方向似乎是行为的原因。

除非另有说明,否则元素宽度默认为其容器的100%。

I just add the DIV tag to md-button with style property of width 100px 我只是将DIV标签添加到宽度为100px的样式属性的md-button

Its Work fine 它的工作很好

 <div style="text-align:center;">
                <md-button ng-click="toggleLeft()" hide-gt-md style="width:100px;">
                    Toggle left
        </md-button></div>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM