HTML 5 <form>很奇怪

时间:2016-01-05 16:14:06

标签: html5 forms web

因此,我目前正在通过表单构建一组3个按钮,并且使用以下代码时遇到了一个我从未见过的奇怪问题:

<div class='logout'>
  <form action='action.php' method='post'>
    <input type='submit' value='H'>
    <input type='text' name='mode' value='0' hidden>
  </form>
</div>
<div class='Mini'>
  <form action='action.php' method='post'>
    <input type='submit' value='M'>
    <input type='text' name='mode' value='MINI' hidden>
  </form>
</div>
<div class='Close'>
   <form action='action.php' method='post'>
     <input type='submit' value='C'>
     <input type='text' name='mode' value='DISPLAY' hidden>
  </form>
</div>

在当前状态下没有显示任何形式,但是当&gt;从关闭表单标签中删除它们变得功能齐全

CSS如下

.logout{
    position:Absolute;
    left:90%;
    top:0%;
}
.Mini{
    position:Absolute;
    left:87%;
    top:0%;
    z-index: 1;
}
.Close{
    position:Absolute;
    left:-130%;
    top:0%;
    z-index: 1;
}

2 个答案:

答案 0 :(得分:0)

正如你在这里看到的那样 - &gt; FIDDLE

你的元素出现了。我假设它是CSS ...你的HTML本身没有任何问题。您需要查看CSS样式并找出未显示的原因。最有可能的是div - &gt;

<div class='logout'>

那是你的问题。

答案 1 :(得分:0)

您的代码运作完美。可能会css div覆盖form display:nonehidden>。如果您删除css,则会破坏某些<div class='logout'> <form action='action.php' method='post'> <input type='submit' value='H'> <input type='text' name='mode' value='0' hidden> </form> </div> <div class='Mini'> <form action='action.php' method='post'> <input type='submit' value='M'> <input type='text' name='mode' value='MINI' hidden> </form> </div> <div class='Close'> <form action='action.php' method='post'> <input type='submit' value='C'> <input type='text' name='mode' value='DISPLAY' hidden> </form> </div>和html。所以你将能够看到所有形式。

以下代码运行并检查:

&#13;
&#13;
Dim year As Int32
If Not Int32.TryParse(TextBox1.Text.Trim(), year) Then
    MessageBox.Show("Please insert a valid year")
    Return
End If
Dim insertSql =
    "INSERT INTO co(community, unit, year, name, roll, mbl) " & vbCrLf & _
    "  SELECT community, unit, year, name, roll, mbl FROM info " & vbCrLf & _
    "  WHERE community = @community AND unit = @unit AND year = @year"
Using con = New SqlConnection("ConenctionString")
    Using cmd As New SqlCommand(insertSql, con)
        cmd.Parameters.Add("@community", SqlDbType.VarChar).Value = ComboBox2.Text
        cmd.Parameters.Add("@unit", SqlDbType.VarChar).Value = ComboBox3.Text
        cmd.Parameters.Add("@year", SqlDbType.Int).Value = year
        con.Open()
        Dim numInserted As Int32 = cmd.ExecuteNonQuery()
    End Using
End Using
&#13;
&#13;
&#13;