看到我在此页面上工作,首先是女性,其次是男性:
http://www.woolovers.com/cashmere-merino/womens/classic-ladies-crew-cardigan.aspx
http://www.woolovers.com/lambswool/unisex/lambswool-slipover-vest.aspx
如您所见,色板顶部的尺寸会有所不同。男性(S M L XL XXL)和女性(S M L XL)
aspx文件中该网格的html是:
<div class="SwatchGrid sw-color">
<div class="sw-item">
<asp:HyperLink ID="lnkColourURL" runat="server">
<asp:Image ID="imgSwatch" runat="server" Height="20px" Width="20px" BorderWidth="0" />
</asp:HyperLink><span><a id="hrfColourLink" runat="server" class="SwatchColourLabel ordr_grid">
<asp:Literal ID="lblColour" runat="server"></asp:Literal></a></span></div>
<div class="sw-sizes-av">
<div id="tdXs" runat="server" visible="false">
<span id="spXS" runat="server" visible="false">
<img id="imgXSarge<%=mstrXSID%>" src="<%=mstrXSURL%>" onclick="ImageClicked('imgXSarge',<%=mstrXSID%>,'<%=mstrXSMsg%>',<%=onXSWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrXSSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrXSTitle%>" title="<%=mstrXSTitle%>"
class="CurPointer" /></span>
</div>
<div id="tdS" runat="server" visible="false">
<span id="spS" runat="server" visible="false">
<img id="imgSmall<%=mstrSID%>" src="<%=mstrSURL%>" onclick="ImageClicked('imgSmall',<%=mstrSID%>,'<%=mstrSMsg%>',<%=onSWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrSSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrSTitle%>" title="<%=mstrSTitle%>"
class="CurPointer" /></span>
</div>
<div id="tdM" runat="server" visible="false">
<span id="spM" runat="server" visible="false">
<img id="imgMedium<%=mstrMID%>" src="<%=mstrMURL%>" onclick="ImageClicked('imgMedium',<%=mstrMID%>,'<%=mstrMMsg%>',<%=onMWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrMSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrMTitle%>" title="<%=mstrMTitle%>"
class="CurPointer" /></span>
</div>
<div id="tdL" runat="server" visible="false">
<span id="spL" runat="server" visible="false">
<img id="imgLarge<%=mstrLID%>" src="<%=mstrLURL%>" onclick="ImageClicked('imgLarge',<%=mstrLID%>,'<%=mstrLMsg%>',<%=onLWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrLSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrLTitle%>" title="<%=mstrLTitle%>"
class="CurPointer" /></span>
</div>
<div id="tdXL" runat="server" visible="false">
<span id="spXL" runat="server" visible="false">
<img id="imgXLarge<%=mstrXLID%>" src="<%=mstrXLURL%>" onclick="ImageClicked('imgXLarge',<%=mstrXLID%>,'<%=mstrXLMsg%>',<%=onXLWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrXLSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrXLTitle%>" title="<%=mstrXLTitle%>"
class="CurPointer" /></span>
</div>
<div id="tdXXXL" runat="server" visible="false">
<span id="spXXXL" runat="server" visible="false">
<img id="imgXXXLarge<%=mstrXXXLID%>" src="<%=mstrXXXLURL%>" onclick="ImageClicked('imgXXXLarge',<%=mstrXXXLID%>,'<%=mstrXXXLMsg%>',<%=onXXXLWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrXXXLSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrXXXLTitle%>" title="<%=mstrXXXLTitle%>"
class="CurPointer" /></span></div>
<div id="tdXXL" runat="server" visible="false">
<span id="spXXL" runat="server" visible="false">
<img id="imgXXLarge<%=mstrXXLID%>" src="<%=mstrXXLURL%>" onclick="ImageClicked('imgXXLarge',<%=mstrXXLID%>,'<%=mstrXXLMsg%>',<%=onXXLWait %>)"
onmouseover="ImageOver(<%=mstrStyleID%>,<%=mstrXXLSwatchID%>,<%=mstrColWay %>,'<%=ImagePath %>','<%=strAlt %>')"
onmouseout="ImageOut(<%=mstrColWay %>)" alt="<%=mstrXXLTitle%>" title="<%=mstrXXLTitle%>"
class="CurPointer" /></span>
</div>
</div>
<div class="cls">
</div>
</div>
<%}
else
{ %>
<%--<div class="sw-item1"> </div>--%>
<div class="sw-sizes">
<div id="tdHXS" runat="server" visible="false">
<span id="spHXS" runat="server" visible="false" >
<asp:Literal ID="Literal1" runat="server" Text="<%$Resources:common,Size_XS%>"></asp:Literal></span></div>
<div id="tdHS" runat="server" visible="false">
<span id="spHS" runat="server" visible="false" >
<asp:Literal ID="Literal2" runat="server" Text="<%$Resources:common,Size_S%>"></asp:Literal></span></div>
<div id="tdHM" runat="server" visible="false">
<span id="spHM" runat="server" visible="false" >
<asp:Literal ID="Literal3" runat="server" Text="<%$Resources:common,Size_M%>"></asp:Literal></span></div>
<div id="tdHL" runat="server" visible="false">
<span id="spHL" runat="server" visible="false" >
<asp:Literal ID="Literal4" runat="server" Text="<%$Resources:common,Size_L%>"></asp:Literal></span></div>
<div id="tdHXL" runat="server" visible="false">
<span id="spHXL" runat="server" visible="false" >
<asp:Literal ID="Literal5" runat="server" Text="<%$Resources:common,Size_XL%>"></asp:Literal></span></div>
<div id="tdHXXXL" runat="server" visible="false">
<span id="spHXXXL" runat="server" visible="false">
<asp:Literal ID="Literal7" runat="server" Text="<%$Resources:common,Size_XXXL%>"></asp:Literal></span></div>
<div id="tdHXXL" runat="server" visible="false">
<span id="spHXXL" runat="server" visible="false">
<asp:Literal ID="Literal6" runat="server" Text="<%$Resources:common,Size_XXL%>"></asp:Literal></span></div>
</div>
<% } %>
现在的问题是,产品上可能有随机尺寸(从小(S)到三重XL(XXXL))。在这种情况下,有4(S / M / L / XL)。现在,如果黑色没有M尺寸,则黑色的S尺寸图像会向右移动(因为.sw-sizes-av具有width:auto)。如何将其和任何其他图像保留在原位置而不将其放置在表布局中?我希望你明白我在这里要说的话。
最佳答案
首先,删除
<div id="ctl00_ContentPlaceHolder1_SwatchGrid1_swl11_tdXXXL">
</div>
和
<div id="ctl00_ContentPlaceHolder1_SwatchGrid1_swl11_tdXs">
</div>
如果不需要的话。我看到标题仅包含S,M,L,XL,XXL,但有7个不同的
<div>
。 XS,S,M,L,XL,XXL,XXXL。如果没有相应的标题,请不要使用div。其次,所有可能/可能没有可用大小的div应该都有一个类。让我们将该类设为
content-size
。您将以下CSS添加到此类中
.content-size{
width:20px; /* because your span has 2px margin */
height:18px;
}
附上相关html的屏幕截图