Как сделать выпадающие списки рядом друг с другом без пробелов и отступов
мой код для выпадающих пунктов ниже. у меня есть отступы:0. тем не мение. это все еще вызывает промежуток между моими тремя пунктами выпадающего списка. Я не хочу места, и все они должны иметь ширину ровно 150 пикселей. не уверен, почему у него все еще есть место. Я думаю, я слишком много думаю.
<asp:DropDownList ID="DropDownList1" runat="server" Width="150px" style="padding:0">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Width="150px" style="padding:0">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server" Width="150px" style="padding:0">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
1 ответ
Решение
Пробел между DropDownLists берется из пробелов (или разрывов строк) в разметке. Вы можете попробовать следующую разметку, чтобы удалить их:
<asp:DropDownList ID="DropDownList1" runat="server" Width="150px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList><asp:DropDownList ID="DropDownList2" runat="server" Width="150px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList><asp:DropDownList ID="DropDownList3" runat="server" Width="150px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
Если Visual Studio стремится автоматически переформатировать его, помещая разрывы строк обратно в разметку, вот еще один способ сделать это, используя элемент таблицы:
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" Width="150px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" Width="150px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" Width="150px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Borough</asp:ListItem>
<asp:ListItem>ZipCode</asp:ListItem>
<asp:ListItem>Address No</asp:ListItem>
<asp:ListItem>Street</asp:ListItem>
<asp:ListItem>Freeform</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>