清除属性未按预期工作

时间:2011-07-19 12:54:25

标签: asp.net html css

这就是我所拥有的:

Label1 Value1 Label2 Value2

Label3 Value3 Label4 Value4

这就是我想要的:

Label1 Value1

Label2 Value2

Label3 Value3

Label4 Value4

不使用中断但使用css中的clear属性。

<div id="leftColumn" style="width:200px; border:1px solid green; float:left; ">
                <asp:Label ID="lblVIN" runat="server" CssClass="label"  meta:resourcekey="lblVINResource" />
                <asp:Label ID="lblVINValue" runat="server" CssClass="value" /> 
                <asp:Label ID="lblYear" runat="server" CssClass="label"  meta:resourcekey="lblYearResource" />
                <asp:Label ID="lblYearValue" runat="server" CssClass="value" />
                <asp:Label ID="lblMake" runat="server" CssClass="label"  meta:resourcekey="lblMakeResource" />
                <asp:Label ID="lblMakeValue" runat="server" CssClass="value" />
                <asp:Label ID="lblModel" runat="server" CssClass="label"  meta:resourcekey="lblModelResource" />
                <asp:Label ID="lblModelValue" runat="server" CssClass="value" />
                <asp:Label ID="lblSeries" runat="server" CssClass="label"  meta:resourcekey="lblSeriesResource" />
                <asp:Label ID="lblSeriesValue" runat="server" CssClass="value" />
                <asp:Label ID="lblColour" runat="server" CssClass="label"  meta:resourcekey="lblColourResource" />
                <asp:Label ID="lblColourValue" runat="server" CssClass="value" />
                <asp:Label ID="lblCylinders" runat="server" CssClass="label"  meta:resourcekey="lblCylindersResource" />
                <asp:Label ID="lblCylindersValue" runat="server" CssClass="value" />
                <asp:Label ID="lblFuelType" runat="server" CssClass="label"  meta:resourcekey="lblFuelTypeResource" />
                <asp:Label ID="lblFuelTypeValue" runat="server" CssClass="value" />
                <asp:Label ID="lblAxels" runat="server" CssClass="label"  meta:resourcekey="lblAxelsResource" />
                <asp:Label ID="lblAxelsValue" runat="server" CssClass="value" />
                <asp:Label ID="lblNSCNumber" runat="server" CssClass="label"  meta:resourcekey="lblNSCNumberResource" />
                <asp:Label ID="lblNSCNumberValue" runat="server" CssClass="value" />

            </div>

到目前为止这是css ......

   <style type="text/css" >
    .label{ color:Blue; clear:right;}
    .value{ color:Orange; clear:right;}
</style>

提前致谢。

2 个答案:

答案 0 :(得分:3)

你没有漂浮任何东西然后清除任何东西。

查看this fiddle

.label{ color:Blue; float:left;clear:left;}
.value{ color:Orange; float:left;}

答案 1 :(得分:0)

您可以将float属性赋予label标签,并将clear和float属性赋值为value以获得所需的结果