none
"Div"的浮动问题??? 江湖救急,Why? RRS feed

  • 问题


  • <div style="height:36px;">
                    <div style="margin-margin-width:70px; height:35px; float:left;">
                    <asp:Label ID="Label6" runat="server" Text="355.55" Font-Size="Small"></asp:Label>
                    </div>
                    <div style="margin-margin-width:50px; height:35px; float:left;">
                    <asp:Button ID="Button2"  runat="server" Text="吸合"  CssClass="button blue small"/>
                    </div>
                </div>

                <div style="height:36px;">
                   
                    <div style="margin-margin-width:70px; height:35px; float:left;">
                    <asp:Label ID="Label7" runat="server" Text="355.55" Font-Size="Small"></asp:Label>
                    </div>
                    <div style="margin-margin-width:50px; height:35px; float:left;">
                    <asp:Button ID="Button3"  runat="server" Text="吸合"  CssClass="button blue small"/>
                    </div>
                   
                </div>

                <div style="height:36px;">
                     <div style="margin-margin-width:70px; height:35px; float:left;">
                    <asp:Label ID="Label8" runat="server" Text="355.55" Font-Size="Small"></asp:Label>
                    </div>
                    <div style="margin-margin-width:50px; height:35px; float:left;">
                    <asp:Button ID="Button4"  runat="server" Text="吸合"  CssClass="button blue small"/>
                    </div>
                </div>


    问题:
            为什么后面两个Div的“float:left;”不是相对于它的“父元素Div”,而是相对于前一个有“float:left;”属性的“Div”进行平移的?   
            
           怎么样才能让它们相对于其父元素“Div”平移?

           在“VS2012”里面看着3个Div层是对齐的,但在浏览器里面却是后面2个层依次向后偏移了,为什么???
     

           

          后面的Div向左浮动,应该是碰到它们的父元素,为什么会碰到前面的浮动框呢???


    Science and technology is my lover.

    2014年5月4日 8:12

全部回复

  • 你好,

      我认为你的Div定位可能存在问题,因为我无法重现你的问题,只能建议你尝试使用    ('"position":absolute;index:10px;'):

     <div style="height:39px;"position":absolute ;z-index:10px; top: 15px; left: 10px;">
                    <div style="margin-margin-width:70px; height:35px; float:left;">
                    <asp:Label ID="Label6" runat="server" Text="355.55" Font-Size="Small"></asp:Label>
                    </div>
                    <div style="margin-margin-width:50px; height:35px; float:left;">
                    <asp:Button ID="Button2"  runat="server" Text="吸合"  CssClass="button blue small"/>
                    </div>
                </div>
    
                <div style="height:37px;"position":absolute;z-index:10px; top: 58px; left: 13px;">
                   
                    <div style="margin-margin-width:70px; height:35px; float:left;">
                    <asp:Label ID="Label7" runat="server" Text="355.55" Font-Size="Small"></asp:Label>
                    </div>
                    <div style="margin-margin-width:50px; height:35px; float:left;">
                    <asp:Button ID="Button3"  runat="server" Text="吸合"  CssClass="button blue small"/>
                    </div>
                   
                </div>
    
                <div style="height:36px;"position":absolute;z-index:10px; top: 106px; left: 15px;">
                     <div style="margin-margin-width:70px; height:35px; float:left;">
                    <asp:Label ID="Label8" runat="server" Text="355.55" Font-Size="Small"></asp:Label>
                    </div>
                    <div style="margin-margin-width:50px; height:35px; float:left;">
                    <asp:Button ID="Button4"  runat="server" Text="吸合"  CssClass="button blue small"/>
                    </div>
                </div>

    在设计视图中,你能通过移动Up/Down/Left/Right 调整div的相对位置。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.






    2014年5月6日 3:25
    版主