【问题标题】:How to align two column together in a <a tag如何在<a标签中将两列对齐
【发布时间】:2014-03-27 15:50:13
【问题描述】:

我试图对齐或将此 HTML 放在同一行

实际输出是这样的

 Cart:

 Payment >>

 Add another item >>

 Product    Price   Quantity

 Toaster    19.99    1         Update Cart                            
                                             Remove from Cart <== I want this column align with
                                                                  the update cart or on the same
                                                                  line

 Total                     19.99

我希望更新购物车和删除在不同的行但对齐 或者让它们在同一行

这里是 Index.cshtml

        @{int ix = 0;}

        @foreach (var item in Model.CartItems)
        {
           <tr id="row-@item.ProductId">
              <td>
                   @Html.ActionLink(item.Produit.Description, "Details", "Product", new { id = 
                        item.ProduitId }, null)
              </td>
              <td>
                @item.Product.Price
              </td>
              <td>
                @Html.TextBoxFor(model => model.CartItems[ix].Quantity, 
                    new  {style = "width:30px; text-align:right;",
                    onkeyup = "clearUpdateMessage();",
                    onchange = "clearUpdateMessage();"
                    }) 
              </td>
              <td>
                <a href="#" class="RefreshQuantity" data-id="@item.PanierId" 
                    id="CartItems_@(ix)__Quantity"> Update Cart >> <a />
              </td>

              <td>
                 <a href="#" class="RemoveLink" data-id="@item.PanierId"> Remove from Cart >> 
                 </a>
              </td>
           </tr>
           ix++;
      }

【问题讨论】:

    标签: html asp.net-mvc-4 c#-4.0


    【解决方案1】:

    您需要在单个 td 上设置 css 宽度属性。

     <td style="width: 100px"> //or use % if your planning on multiple media</td>
     <td style="width: 100px:> </td>
    

    相应地设置 td 的大小。

    你可能想看看Twitter Bootstrap,这个库让CS​​S很容易用类来操作

    更新:

    使用 % 代替像素很难在小样本中显示。我不知道您在切换媒体时希望您的屏幕是什么样子。可以很简单,就像您希望在交换媒体时缩小屏幕一样。

     <td style="width: 15%"> </td>
    

    如果您切换到像手机一样小的东西,您可能想要更改布局,在这种情况下,您需要为特定媒体创建 css 类。

    随着世界向Write Once, Run Anywhere (WORA) 开发(twitter bootstrap、xamarin、PhoneGap 等)发展,您必须自己决定最适合您的情况。

    更新:

    Here is a fiddle of what I am suggesting

    【讨论】:

    • 你能给我一个例子吗?你所说的媒体是什么意思?
    • 我把我的输出布局(见我对问题的描述)我尝试了每个宽度:100 px,但结果和我在描述中所说的完全一样
    • 尝试减小 px 大小,看看是否会得到不同的结果。
    • 我正在尝试 CTRL-F5 刷新 CSS(使用 Chrome),因为有时 Css 不刷新。到目前为止与 50px 相同的问题
    • 它正在工作。我没有意识到 style="width:100px" 应该在 我把它放在
    猜你喜欢
    • 2014-07-06
    • 1970-01-01
    • 2016-06-08
    • 1970-01-01
    • 2018-03-11
    • 2013-02-09
    • 1970-01-01
    • 2020-05-03
    • 2022-11-25
    相关资源
    最近更新 更多