html - Material Design Lite 表单按钮不提交任何内容

标签 html css material-design-lite http-request

我是 CSS 的新手,可能会错过一些基本的东西。我从 Material Design Lite 的教程站点获取 HTML 表单的代码,但它不发送任何 HTTP 请求。

我错过了什么?

<div class="mdl-layout mdl-js-layout mdl-color--grey-100">
    <main class="mdl-layout__content">
        <div class="mdl-card mdl-shadow--6dp">
            <div class="mdl-card__title mdl-color--primary mdl-color-text--white">
                <h2 class="mdl-card__title-text">Acme Co.</h2>
            </div>
        <div class="mdl-card__supporting-text">
                <form action="foo.html">
                    <div class="mdl-textfield mdl-js-textfield">
                        <input class="mdl-textfield__input" type="text" id="username" />
                        <label class="mdl-textfield__label" for="username">Username</label>
                    </div>
                    <div class="mdl-textfield mdl-js-textfield">
                        <input class="mdl-textfield__input" type="password" id="userpass" />
                        <label class="mdl-textfield__label" for="userpass">Password</label>
                    </div>
                </form>
            </div>
            <div class="mdl-card__actions mdl-card--border">
                <button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">Log in</button>
            </div>
        </div>
    </main>
</div>

最佳答案

把你的 <Button>里面<form></form>标签。

像这样:

<div class="mdl-layout mdl-js-layout mdl-color--grey-100">
    <main class="mdl-layout__content">
        <div class="mdl-card mdl-shadow--6dp">
            <div class="mdl-card__title mdl-color--primary mdl-color-text--white">
                <h2 class="mdl-card__title-text">Acme Co.</h2>
            </div>
        <div class="mdl-card__supporting-text">
                <form action="foo.html">
                    <div class="mdl-textfield mdl-js-textfield">
                        <input class="mdl-textfield__input" type="text" id="username" />
                        <label class="mdl-textfield__label" for="username">Username</label>
                    </div>
                    <div class="mdl-textfield mdl-js-textfield">
                        <input class="mdl-textfield__input" type="password" id="userpass" />
                        <label class="mdl-textfield__label" for="userpass">Password</label>
                    </div>
                    <div class="mdl-card__actions mdl-card--border">
                        <button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" type="submit" name="login">Log in</button>
                    </div>
                </form>
            </div>
        </div>
    </main>
</div>

关于html - Material Design Lite 表单按钮不提交任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39561484/

相关文章:

python - 如何使用 beautifulsoup 从下面的 HTML 代码中提取数据?

html - 停止 jupyter notebook 在 pandas html 表输出中包装单元格内容

html - 何时为元标记使用属性属性?

html - 整个 body 的移动

javascript - MDL 表检索数据检查值

javascript - ajax查询中从div获取数据

html - 使用 CSS 水平滚动列表

css - <button> 中的垂直对齐元素作为 flex 元素

material-design-lite - 如何使用 javascript 隐藏 MDL 工具提示

forms - 如何在 Material Design Lite 中根据表单内容启用/禁用提交按钮?