0

我创建了一个输入文本字段并使用 html 为其指定了一个标签,但是我没有在一行中显示标签,而是面临标签显示为三行的问题。

label {
  display: inline-block;
  position: relative;
  width: 5px;
  top: 0px;
  left: -193px;
  color: #999;
  font-family: 'Helvetica', sans-serif;
  font-size: 16px;
  font-weight: lighter;
  z-index: 1;
  transition: all 0.2s ease-in;
}
<input type="text" name="verficationcode" required autocomplete="off">
<label for="verficationcode">Enter code here</label>

图片

4

4 回答 4

1

注释掉或调整width属性:

label {
    display: inline-block;
    position: relative;
    /*width: 5px;*/
    top: 0px; 
    /*left: -193px;*/
    color: #999;
    font-family: 'Helvetica', sans-serif;
    font-size: 16px;
    font-weight: lighter;
    z-index: 1;
    transition: all 0.2s ease-in;
}
<input type="text" name="verficationcode" required autocomplete="off">
<label for="verficationcode">Enter code here</label>

于 2017-11-28T06:49:34.763 回答
0

请查看以下代码。从 CSS 中移除此处不需要的 position、left、top 属性。

label{
    display: inline-block;
    width: auto;
    color:#999;
    font-family:'Helvetica', sans-serif;
    font-size:16px;
    font-weight: lighter;
    z-index:1;
    transition: all 0.2s ease-in;
}
<input type="text" name="verficationcode" required autocomplete="off">
<label for="verficationcode">Enter code here</label>

也许它会帮助你。谢谢。

于 2017-11-28T07:02:13.577 回答
0

试试这个CSS,

label{
    white-space:nowrap;
}

但你可以使用占位符而不是这样的标签

<input type="text" name="verficationcode" required autocomplete="off" placeholder="Enter verification code here">
于 2017-11-28T06:49:37.507 回答
0

更改 html 的位置并使用此 css

label{
    display: inline-block;
    position: relative;
    top:0px; 
    padding-right:15px;
    color:#999;
    font-family:'Helvetica', sans-serif;
    font-size:16px;
    font-weight: lighter;
    z-index:1;
    transition: all 0.2s ease-in;
}

label{
    display: inline-block;
    position: relative;
    top:0px; 
    padding-right:15px;
    color:#999;
    font-family:'Helvetica', sans-serif;
    font-size:16px;
    font-weight: lighter;
    z-index:1;
    transition: all 0.2s ease-in;
}
<label for="verficationcode">Enter code here</label>
<input type="text" name="verficationcode" required autocomplete="off">

于 2017-11-28T06:53:29.690 回答