0

I have an asp menu, I want to float it to left so the element after it can come to its right side (beside) it. I've set a CssClass for the Menu and added float: leftto it, but it is not working. I've even changed the float:left to float:right to see if it will work or not, but nothing worked.

Here is my code:

 <form id="form1" runat="server">
        <div class="wrapper">
        <div class="navbar">


        /*some code*/

     </div>

    <div class="middle"> 



    <asp:Menu ID="MenuRec" runat="server" CssClass="recFriends">
         <Items>
            <asp:MenuItem Text="People you may know:" Selectable="false" Enabled="false"></asp:MenuItem>
            <asp:MenuItem Text="<br/>" Selectable="false" Enabled="false"></asp:MenuItem>

        </Items>

         <Items>
            <asp:MenuItem Text=" Item1"  Selectable="false"></asp:MenuItem>
            <asp:MenuItem Text=" Item2"  Selectable="false"></asp:MenuItem>
             <asp:MenuItem Text=" Item3" Selectable="false"></asp:MenuItem>
        </Items>
    </asp:Menu>



          <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
            <!--here goes the customized content--> 
        </asp:ContentPlaceHolder>

  </div>
     <div class="footer">

    </div>
</div>
</form>

</body>

My CSS:

.recFriends {

    float:left;  
    padding-top:1em;
    color:#003366; 
    font-weight:normal;
    font-style:italic; 
}

controls inside the ContentPlaceHolder (which will be in a page that inherits from this master page) must come to the right of the menu, but these are coming below it instead.

I've searched a lot, but nothing worked, I've even checked the solutions available here:

CssClass is not working for my asp menu - all code attached

asp Menu control not floating properly

Can anyone tell me how to solve this problem?

Thank you.

4

1 回答 1

1

将菜单包装在 div 中,并在内容占位符之前关闭 div。将 CSS 类从菜单移动到容器 div。

HTML

  <div class="recFriends">
            <asp:Menu ID="MenuRec" runat="server">
                <Items>
                    <asp:MenuItem Text="People you may know:" Selectable="false" Enabled="false"></asp:MenuItem>
                    <asp:MenuItem Text="<br/>" Selectable="false" Enabled="false"></asp:MenuItem>

                </Items>

                <Items>
                    <asp:MenuItem Text=" Item1" Selectable="false"></asp:MenuItem>
                    <asp:MenuItem Text=" Item2" Selectable="false"></asp:MenuItem>
                    <asp:MenuItem Text=" Item3" Selectable="false"></asp:MenuItem>
                </Items>
            </asp:Menu>
        </div>
        <asp:ContentPlaceHolder ID="MainContent" runat="server">
            <!--here goes the customized content-->
        </asp:ContentPlaceHolder>

CSS

 .recFriends {
        float: left;
        padding-top: 1em;
        color: #003366;
        font-weight: normal;
        font-style: italic;
        width: 20%;
        padding-left: 2em;
    }

样本

于 2015-11-11T16:40:58.387 回答