0

只是运行准系统“material-components-web”,我无法让输入字段看起来像它应该的那样。JS 交互效果很好。主题看起来不错。但是我的领域正在被切断在此处输入图像描述

索引.html:

<html>
 <head>
   <link rel="stylesheet" href="bundle.css">
   <link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,700,700i" rel="stylesheet">
 </head>
 <body class="mdc-typography">
    <h1 class="mdc-typography--headline1">Big header</h1>
    <div class="mdc-text-field" data-mdc-auto-init="MDCTextField">
      <input class="mdc-text-field__input" type="text" id="input">
      <label for="input" class="mdc-floating-label">Input Label</label>
      <div class="mdc-line-ripple"></div>
    </div>

    <!-- at the bottom of the page -->
    <script src="bundle.js"></script>
</body>
</html>

应用程序.scss:

@import "material-components-web/material-components-web";

应用程序.js:

import * as mdc from 'material-components-web'
mdc.autoInit()

我没有其他文件拉进来。没有添加其他样式。会发生什么?

4

2 回答 2

1

这通常发生在.mdc-text-field__input不正确的情况下box-sizing(例如,继承 parent.mdc-text-field的边框框)。请确保.mdc-text-field__input具有初始框大小:

.mdc-text-field__input {
  box-sizing: initial; // or content-box
}
于 2018-07-03T07:10:44.393 回答
0

以下对我有用:将以下内容添加到自定义样式表中。

.mdc-text-field {
  width: -webkit-fill-available;
  width: fill-available;
}
于 2021-01-23T23:55:49.800 回答