【问题标题】:Materialize Design物化设计
【发布时间】:2017-07-31 01:31:01
【问题描述】:

物化表单输入域设计的视图是否可以改变?

我想将具体化输入字段更改为图像中提到的引导字段。 这是我真正想要的图像。 Image

<div class="input-field col s2">
    <input style="font-weight: bold;" id="yearfrom" name="yearfrom"
          value="${parts.yearfrom}" type="text">
    <label for="yearfrom"><strong>YearFrom</strong></label>
</div>

【问题讨论】:

  • 是的,有可能。
  • 这怎么可能?请给我一个演示。 #迈克尔·科克
  • 您需要试一试,让我们知道您遇到了什么问题。
  • 我已经在我的问题中上传了一张图片,请您检查一下。我上传了正在使用的代码。
  • 我只想更改字段设计。请你看看图片。

标签: html css bootstrap-modal materialize form-fields


【解决方案1】:

您需要覆盖具有输入字段样式的 SASS 文件。根据您的设计开始的好地方是在输入字段周围添加边框。

【讨论】:

  • 请您再解释一下。
  • MaterializeCSS 中的每个组件都定义在一个主 sass 文件中。例如,当您在输入字段内单击时出现的活动颜色已被定义。因此,如果您想更改该颜色,则需要使用相同的类名使用 CSS 覆盖它。同样的事情也适用于您的边框,您只有一个边框底部,但从您发布的图片来看,您需要四面八方的边框。您将需要使用 CSS 覆盖它。使用检查元素,找出类名,然后添加所需的样式。
【解决方案2】:

.bootstrap {
   margin-bottom: 15px;
}
.bootstrap .form-control:focus {
    border-color: #66afe9 !important;
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
}
.bootstrap .form-control {
    display: block;
    width: 100%;
    height: 20px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555 !important;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc !important;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075) !important;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s !important;
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s !important;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s !important;
}
.bootstrap label {
    display: inline-block;
    max-width: 100%;
    margin-bottom: 5px;
    font-weight: 700;
    color: #000 !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css" rel="stylesheet"/>
Materialize<br><br>
<div class="row">
    <div class="input-field col s12">
      <input id="first_name1" type="text" class="validate">
      <label for="first_name1">First Name</label>
    </div>
  </div>
  
  
  Bootstrap<br><br>
  
  <div class="row">
    <div class="col s12 bootstrap">
      <label for="first_name2">First Name</label>
      <input class="form-control" id="first_name2" type="text" class="validate">
    </div>
  </div>

【讨论】:

  • 我在 materialize.css 中进行了更改。为左上角添加边框。但在浏览器中没有效果。当我执行代码时,更改不适用。
  • 浏览器这些天保存缓存中的所有内容,因此您需要删除浏览器缓存或打开开发者模式并在 chrome ctrl +shift + r 中进行硬刷新或右键单击重新加载按钮顶栏。正如您所看到的,它在我制作的 sn-p 中工作,并确保将类表单控件添加到输入标签,并用引导类替换输入字段类并将标签标签向上移动
猜你喜欢
  • 1970-01-01
  • 2016-11-11
  • 2018-11-09
  • 1970-01-01
  • 1970-01-01
  • 2016-05-23
  • 1970-01-01
  • 2016-04-01
  • 2017-07-04
相关资源
最近更新 更多