简体   繁体   English

如何将垂直子菜单项与父菜单对齐

[英]How to align vertical submenu items with parent menu

I have a vertical menu which shows submenu items on hover.I want to align the submenu according to the parent menu item. 我有一个垂直菜单,该菜单显示悬停时的子菜单项。我想根据父菜单项对齐子菜单。 i am bringing the menu and submenu items through a repeater. 我通过中继器带来菜单和子菜单项。 i want the submenus to be reponsive as shown in the images. 我希望子菜单能够响应,如图所示。 Use this link for example: http://www.industrybuying.com/ 例如,使用此链接: http : //www.industrybuying.com/

    <div class="vertical-menu-content">
                                <ul class="vertical-menu-list">
                                    <asp:Repeater ID="rptVerticalMenu" runat="server" OnItemDataBound="rptVerticalMenu_ItemDataBound">
                                        <ItemTemplate>

                                            <li class="vertical-menu4">
                                                <a href="Product_List.aspx?cat=<%#Eval("BasicCategoryName")%>" class="parent linkSize">
                                                    <asp:Label ID="lblCatList" runat="server" Text='<%#Eval("BasicCategoryName")%>'></asp:Label>
                                                </a>
                                                <div class="vertical-dropdown-menu">
                                                    <div class="vertical-groups">
                                                        <div class="row">
                                                            <div class="col-sm-4">
                                                                <div class="block-content-vertical-menu border-left">
                                                                    <h3 class="head">CATEGORIES</h3>
                                                                    <div class="inner">
                                                                        <ul class="vertical-menu-link">
                                                                            <asp:Repeater ID="rptVerticalSubMenu" runat="server">
                                                                                <ItemTemplate>
                                                                                    <li>
                                                                                        <a href="Product_List.aspx?cat=<%#Eval("CategoryName")%>">
                                                                                            <asp:Label ID="lblCatName" runat="server" CssClass="text" Text='<%#Eval("CategoryName")%>'></asp:Label>

                                                                                        </a>
                                                                                    </li>
                                                                                </ItemTemplate>
                                                                            </asp:Repeater>
                                                                        </ul>
                                                                    </div>
                                                                </div>
                                                            </div>

                                                           <%-- <div class="col-sm-4">
                                                                <div class="block-content-vertical-menu border banner-hover">
                                                                    <a href="#">
                                                                        <img src="WebTheme/TransMax/data/banner/b42.png" alt="Banner"></a>
                                                                </div>
                                                            </div>--%>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>

                                        </ItemTemplate>
                                    </asp:Repeater>



                                </ul>
                            </div>

You could take the classes for the UL elements plus the Header tag (h3) and reset the browsers default margin and padding properties to your settings. 您可以选择UL元素的类以及Header标签(h3),然后将浏览器的默认边距和填充属性重置为您的设置。

.vertical-menu-list, .vertical-menu-link, h3{
    margin: 5px;
    padding:5px;
}

Or target the elements themselves. 或针对元素本身。

ul, h3{
    margin: 5px;
    padding:5px;
}

This all depends on there being no other margin or padding styles on the other elements in between. 这完全取决于其他元素之间没有其他边距或填充样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM