Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hey Guys,

I created a menu control, paired it with web.sitemap where I put the items I want to see in the page. I was able to change the look of the menu from css by adding ID in the menu control. But I cant find where should I do the changes to add space on each menu.

Here's my web.sitemap file
XML
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
        
         <siteMapNode url="~/" title="Home"  description="Home">
        <siteMapNode url="Default.aspx" title="Home"  description="Go to HomePage" />
        
        <siteMapNode url="~/Forum/Forum.aspx" title="Forums" description="Go to Forums" >
        <siteMapNode url="~/Forum/AnimeForum.aspx" title="Anime"  description="Anime Discussion" />
        <siteMapNode url="~/Forum/GamesForum.aspx" title="Games"  description="Gaming Discussion" />
        <siteMapNode url="~/Forum/HardwareForum.aspx" title="Hardware"  description="Hardware Discussion" />
        <siteMapNode url="~/Forum/SoftwareForum.aspx" title="Software"  description="Software Discussion" />
        </siteMapNode>
  
        <siteMapNode url="ContentList.aspx" title="Content"  description="Go to Reviews and News">
        </siteMapNode>

        <siteMapNode url="VideoList.aspx" title="Video"  description="Go to Videos" >
        </siteMapNode> 
    </siteMapNode>
</siteMap>



And her's the code in the masterpage that holds the menu
ASP.NET
<nav id="Nav">

       <asp:Menu ID="Menu1" runat="server" CssClass="MainMenu" DataSourceID="SiteMapDataSource1" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
       </asp:Menu>

           <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
           <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath><br /> 
        
       </nav>


Here's the css code:
CSS
 #Menu1{
Padding-Left :80px;
 }




Thanks,
Posted
Updated 22-Feb-14 22:53pm
v5

You can use css Padding for that.

C#
.yourClass
{
padding-left:50px;
}


Live demo : CSS Padding

CSS Padding

UPDATE
XML
<asp:Menu ID="Menu1" runat="server"  DataSourceID="SiteMapDataSource1"
        RenderingMode="List" StaticDisplayLevels="2" CssClass="MainMenu">
    <LevelMenuItemStyles>
         <asp:MenuItemStyle CssClass="SiteMapLevel1" />
         <asp:MenuItemStyle CssClass="SiteMapLevel2" />
     </LevelMenuItemStyles>

</asp:Menu>



CSS

C#
.SiteMapLevel1
{
    padding-bottom: 5px;
    padding-top: 5px;

}

.SiteMapLevel2
{

    padding-bottom: 5px;
    padding-top: 5px;
}


Check here for more info : Using CSS and Styles with the Menu Control
 
Share this answer
 
v3
Comments
KatsuneShinsengumi 23-Feb-14 3:50am    
Hey,

I tried this already, my problem is that the whole menu objects are moving left instead of having 50px space in ever left side of each menu item.
Sampath Lokuge 23-Feb-14 3:58am    
Can you put your html and css code snippets for your menu.Then only we can give an exact solution for you.
KatsuneShinsengumi 23-Feb-14 4:24am    
I update the question so you can see it.
Sampath Lokuge 23-Feb-14 4:38am    
Where's the code snippet for your css 'MainMenu' ?
KatsuneShinsengumi 23-Feb-14 4:54am    
There it is. Please take a look.
use & nbsp after each menu...:)
 
Share this answer
 
Comments
KatsuneShinsengumi 23-Feb-14 4:26am    
The declaration of the menu objects are inside an xml file. I'm also trying to use the   but the code always give error inside the xml file. Please see the code I add it in my question.

Thanks,
Hey Guys,

Just for the sake of not letting this hang without an answer I'll just make my menu items static for now. I won't use web.sitemap and just add the item menus in the masterpage where the menu is located, give them id and use those id in css to manipulate them.

Thanks,
 
Share this answer
 
v2
try and use $#160 in xml file...after the menu's

thanks...:)
 
Share this answer
 
v2
Comments
KatsuneShinsengumi 23-Feb-14 7:01am    
I also tried that, I got the code from stackoverflow, it works on texts inside hovers. But it doesnt move the menu items.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900