首页 > 解决方案 > 如何在输入标签之前显示标签

问题描述

我试图在 UI 中输入标签之前获取标签。但就我而言,我得到的输出如下图所示。

下面是我的代码示例。请帮助我进行更改,以便我可以获得所需的输出。

我的代码示例:

<form method="post" action="">
    Vector Name: <input name="vectorName" /><br/>
    Vector IP Address: <input type="password" name="ip"/><br/>
    Vector Serial Number: <input type="password" name="serial" /><br/> 
</form>

在此处输入图像描述

标签: htmlasp.net-mvcrazor

解决方案


请将您的代码替换为:

.block label{
      display: inline-block;
      width: 180px;
      text-align: right;
}
.block{
  margin-top:10px;
}
<form method="post" action="">
      <div class="block">
          <label>Vector Name:</label>
          <input type="text" name="vectorName" />
      </div>
      <div class="block">
          <label>Vector IP Address:</label>
          <input type="password" name="ip"/>
      </div>
      <div class="block">
          <label>Vector Serial Number:</label>
          <input type="password" name="serial"/>
      </div>
</form>


推荐阅读