gpt4 book ai didi

html - 表格间距问题

转载 作者:行者123 更新时间:2023-11-28 10:32:10 24 4
gpt4 key购买 nike

我已经建立了一个表,该表根据运行的存储过程进行填充。包含表格的 div 的宽度是页面的 96%。表格的宽度为 100%。我遇到的问题是当我有两到三个元素填充表时,元素之间有很大的空间。我在表中指定了空间,但这不起作用。我也有字体是黑色的问题。我删除了与 <a></a> 相关的所有 CSS。超链接,但它仍然没有显示正确的字体颜色。有什么建议吗?

 Dim con5 As New SqlConnection
Dim cmd5 As New SqlCommand
Dim index As Integer = 0
Dim dt1 As New DataSet




con5.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
con5.Open()
cmd5.Connection = con5
cmd5.CommandType = CommandType.StoredProcedure


cmd5.CommandText = "ProductBreakdown"

cmd5.Parameters.Add(New SqlParameter("ProductID", SqlDbType.Int)).Value = Session("Product")
cmd5.Parameters.Add(New SqlParameter("DesignName", SqlDbType.VarChar, 50)).Value = Request.QueryString("o")




Dim da1 As SqlDataAdapter = New SqlDataAdapter(cmd5)
da1.Fill(dt1)

Dim table1 As New HtmlTable

Dim numells As Integer = 6


dv = New DataView(dt1.Tables(0))
Dim tablestring = ""
Dim strTable As New StringBuilder()
Dim rowIsOpen As Boolean = False
Dim itmCounter As Integer = 0
strTable.Append("<table width=""100%"" ""cellspacing=10px"" ""cellpadding=10px""> ")

For Each dr As DataRowView In dv



Dim crossover As String = dr("CrossoverID").ToString()
Dim picid As String = dr("Description").ToString()
Dim picdescrip As String = dr("DesignColor").ToString().ToUpper()
Dim collectionname As String = dr("CollectionDescription").ToString().ToUpper()
Dim designinfo As String = dr("DesignName").ToString()
Session("Collection") = dr("CollectionDescription").ToString()
'collectionname.ToUpper()
' For every 5 items create a new row.
If itmCounter Mod 4 = 0 Then
' Since we want new row, first close any open row
If rowIsOpen Then strTable.Append("</tr>")

' Start a new row and mark row as open so we can keep track
strTable.Append("<tr>")
rowIsOpen = True
End If


strTable.Append("<td><a href=""Sheet Vinyl Tile Product Page.aspx?p=" & crossover & "&o=" & designinfo & """>")
strTable.Append("<img src=""Images/Products/" + picid + ".jpg""width=""188"" height=""188"" border=""0"""" /><br/><br/>")
strTable.Append("<b><color=Black>" & collectionname & "</b><br />")
strTable.Append(picdescrip & "</a></td>")

itmCounter += 1

Next
' Next

' Make sure we close any open rows
If rowIsOpen Then strTable.Append("</tr>")

If strTable.Length > 0 Then
product.InnerHtml = "<table>" & _
strTable.ToString() & _
"</table>"
End If

最佳答案

表格在 HTML 中具有特定的作用,但您可能希望在这种情况下使用 DIV。 DIV 将根据浏览器的宽度自动 float 和重新定位。

这是 jsFiddle 中的示例

HTML

<div class="table">
<div class="banner">The preferred developer response</div>
<div class="cell">
<img src="happy-icon.png">
</div>
...
<div class="banner">Other emotions</div>
<div class="cell">
<img src="sad-icon.png">
</div>
...
</div>

CSS

.table {
margin-left: 50px;
margin-right: 50px;
}
.banner {
padding: 10px;
margin-top: 20px;
clear: both;
background-color: #336699;
color: white;
font-weight: bold;
}
.cell {
width: 150px;
float: left;
}

你的代码可能是这样的

Dim con5 As New SqlConnection
Dim cmd5 As New SqlCommand
Dim index As Integer = 0
Dim dt1 As New DataSet

con5.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
con5.Open()
cmd5.Connection = con5
cmd5.CommandType = CommandType.StoredProcedure
cmd5.CommandText = "ProductBreakdown"
cmd5.Parameters.Add(New SqlParameter("ProductID", SqlDbType.Int)).Value = Session("Product")
cmd5.Parameters.Add(New SqlParameter("DesignName", SqlDbType.VarChar, 50)).Value = Request.QueryString("o")


Dim da1 As SqlDataAdapter = New SqlDataAdapter(cmd5)
da1.Fill(dt1)

dv = New DataView(dt1.Tables(0))

Dim strTable As New StringBuilder()
Dim itmCounter As Integer = 0
strTable.Append("<div class=""table""> ")

For Each dr As DataRowView In dv

Dim crossover As String = dr("CrossoverID").ToString()
Dim picid As String = dr("Description").ToString()
Dim picdescrip As String = dr("DesignColor").ToString().ToUpper()
Dim collectionname As String = dr("CollectionDescription").ToString().ToUpper()
Dim designinfo As String = dr("DesignName").ToString()
Session("Collection") = dr("CollectionDescription").ToString()

strTable.Append("<div class=""cell""><a href=""Sheet Vinyl Tile Product Page.aspx?p=" & crossover & "&o=" & designinfo & """>")
strTable.Append("<img src=""Images/Products/" + picid + ".jpg""width=""188"" height=""188"" border=""0"""" /><br/><br/>")
strTable.Append("<b><color=Black>" & collectionname & "</b><br />")
strTable.Append(picdescrip & "</a></div>")

itmCounter += 1

Next
strTable.Append("</div>")
product.InnerHtml = strTable.ToString()

同样美味但卡路里更少

关于html - 表格间距问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23482138/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com