【问题标题】:Email input field width changes only with inline style电子邮件输入字段宽度仅随内联样式更改
【发布时间】:2019-07-21 03:01:25
【问题描述】:

我有一个电子邮件输入字段,它以内联样式设置为 80% 宽度。我将宽度参数移动到一个宽度为 80% 的类,但现在宽度显示为 100%。

html:

<div class="center_text_grid mktg_text">
<input type="text" class="joinpage_input" autofocus="autofocus" placeholder="Your email address" id="email_field" name="email_field" font-size: 18px;" required></div>

CSS:

.center_text_grid {
    display: grid;
    grid-column: 4 / 15;
    grid-row: 20 / 20;
    display: block;
    overflow: auto;
    padding-left: 0%;
    align-items: center;
    justify-items: center; }

.mktg_text{
    font-family: roboto_thinregular;
    font-size: 13pt;
    color: rgb(117,163,126);
    line-height: 1.5; }

.joinpage_input{
    border-radius: 15px;
    border-style: ridge;
    border-color: rgb(250,250,250);
    border-width: 1px;
    background-color: black;
    height: 45px;
    width: 80%;
    text-align: center;
    font-family: robotoregular;
    font-size: 18pt;
    font-weight: bold;
    color: rgb(150,150,150);
    letter-spacing: 2px; }

::placeholder {
    color: rgb(150,150,150);
    font-family: camphorW01-Thin,calibri,arial;
    font-size: 12pt;
    opacity: 1;
}

为什么不是宽度:80%;控制何时是按钮上的类,而其他两个类没有宽度参数?为什么它可以用作内联样式而不是类样式?

【问题讨论】:

    标签: html css


    【解决方案1】:

    代码可能如下所示:

    .joinpage_input {
      width: 80%;
      height: 45px;
      border: 1px ridge rgb(250, 250, 250);
      border-radius: 15px;
      background-color: black;
      text-align: center;
      font-size: 18pt;
      font-weight: bold;
      color: rgb(150, 150, 150);
      letter-spacing: 2px;
    }
    
    ::placeholder {
      color: rgb(150, 150, 150);
      font-size: 12pt;
    }
    <div>
      <input id="email_field" name="email_field" class="joinpage_input" type="email" placeholder="Your email address" autofocus required>
    </div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2021-12-27
      • 1970-01-01
      • 2012-01-12
      • 2018-01-12
      • 1970-01-01
      • 2014-12-07
      相关资源
      最近更新 更多