简体   繁体   English

ASP.NET表单中的md按钮尺寸不正确

[英]md-button in ASP.NET form is not correctly sized

I have a ASP.NET form in which I'd like to add a md-button but when I put my md-button inside the form it gets resized and it doesn't fit the row as I want it. 我有一个ASP.NET表单,我想在其中添加一个md-button,但是当我将md-button放到表单中时,它会被调整大小,并且不适合我想要的行。

I can't find any documentation on this behaviour, I tried to set the layout on the button itself, put it in a md-input-container, etc... 我找不到有关此行为的任何文档,我试图设置按钮本身的布局,将其放置在md-input-container中,等等。

I want this button in the form so I don't have to rewrite the submit form function myself. 我想要表单中的此按钮,因此不必自己重写提交表单功能。

Here's my form in HTML : 这是我的HTML表单:

<div layout-padding layout="column">
    @using (Html.BeginForm("Login", "Home", FormMethod.Post))
    {
        <md-input-container class="mt-35" layout="row">
            <label>Ton email :</label>
            @Html.TextBoxFor(x => x.Username)
        </md-input-container>
        <md-input-container layout="row">
            <label>Ton mot de passe :</label>
            @Html.PasswordFor(x => x.Password)
        </md-input-container>
        <md-input-container layout="row">
            <md-checkbox aria-label="Rester connecté">
                Rester connecté
            </md-checkbox>
        </md-input-container>
        <md-button class="md-raised md-primary">Me connecter</md-button>
        <!-- This button doesn't fit -->
    }
    <md-button class="md-raised md-primary">Connect with Facebook</md-button>
    <!-- This one does -->
</div>

I didn't change any CSS for these, i'm working with Angular Material 1.1.0 我没有为这些更改任何CSS,我正在使用Angular Material 1.1.0

Here's two screenshots of what I'd like to achieve and what I have now : 这是我想要实现和现在拥有的两个屏幕截图:

我现在有什么 That's what I have now, with the code I wrote above. 这就是我上面编写的代码所拥有的。

我想要的是 That's what I want to achieve. 这就是我要实现的目标。

EDIT : Here's my additional CSS : 编辑:这是我的附加CSS:

.parent {
  overflow: hidden;
}

.card img {
  width: 100%;
  height: auto;
}

.mt-35 {
    margin-top: 35px !important;
}

.mb-35 {
    margin-bottom: 35px !important;
}
.mb-15 {
    margin-bottom: 15px !important;
}
.md-content.md-default-theme, md-content {
    background-color: white !important;
    border-radius: 10px !important;
}
.md-datepicker-input-container {
    width: 100% !important;
}
.md-datepicker-input {
    max-width: 100% !important;
}

Found it ! 找到了 !

The form was messing with the layouts, I have it working by adding the layout attribute in the BeginForm method : 表单弄乱了布局,我通过在BeginForm方法中添加layout属性来使其工作:

@using (Html.BeginForm("Login", "Home", FormMethod.Post, new { @layout = "column" }))
            {
                <md-input-container class="mt-35" layout="row">
                    <label>Ton email :</label>
                    @Html.TextBoxFor(x => x.Username)
                </md-input-container>
                <md-input-container layout="row">
                    <label>Ton mot de passe :</label>
                    @Html.PasswordFor(x => x.Password)
                </md-input-container>
                <md-input-container layout="row">
                    <md-checkbox aria-label="Rester connecté">
                        Rester connecté
                    </md-checkbox>
                </md-input-container>
                <md-button class="md-raised md-primary md-button-no-margin" layout-padding type="submit">Me connecter</md-button>
            }

And custom CSS to get rid of the margin in md-button class : 和自定义CSS来消除md-button类中的空白:

.md-button-no-margin {
    margin: 0 !important;
}

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

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