Click here to Skip to main content
15,887,967 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
hi,

I am creating horizontal menu bar for using css. Its working fine without any droup down menu.
When I wrote css for dropdown menu, its appending to my main menu instead of coming down as dropdown menu.
Please any one help, What i am missing. plzz.
Below are my html
HTML
<div id="talltabs-maroon">
            <ul>
                <li class='@Html.IsActive("Home", "Index")'>
                    <a href=@Url.Action("Index", "Home")>
                        <span class="glyphicon glyphicon-random"></span>
                        @*
                        </p>
                    </a>
                    <ul class="dropdown-content" style="top:100px; left:0">
                        <li>
                            <a href=@Url.Action("Valve", "Report")>
                                ^__i class="ti-receipt">
                                <p>Valve Report</p>
                            </a>
                        </li>
                        <li>
                            <a href=@Url.Action("Valve", "Report")>
                                ^__i class="ti-file">
                                <p>Cylinder Report</p>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>

below are the css for main menu
CSS
#talltabs-maroon {
    clear: left;
    float: left;
    padding: 0;
    border-top: 3px solid #CD324F;
    width: 100%;
    overflow: hidden;
    font-family: Georgia, serif;
    height: 90px;
    position: inherit;
}

    #talltabs-maroon ul {
        float: left;
        margin: 0;
        padding: 0;
        list-style: none;
        position: relative;
        left: 50%;
        text-align: center;
    }

        #talltabs-maroon ul li {
            display: block;
            float: left;
            list-style: none;
            margin: 0;
            padding: 0;
            position: relative;
            right: 50%;
        }

            #talltabs-maroon ul li a {
                display: block;
                float: left;
                margin: 0 3px 0 0;
                padding: 0px 10px 6px 10px;
                background: #CD324F;
                text-decoration: none;
                color: #fff;
            }

                #talltabs-maroon ul li a p:hover {
                    color: aqua;
                }

                #talltabs-maroon ul li a:hover {
                    padding: 20px 10px 6px 10px;
                    color: black
                }

            #talltabs-maroon ul li.active a,
            #talltabs-maroon ul li.active a:hover {
                padding: 25px 10px 6px 10px;
                border-width: 5px;
                border-color: aqua;
                color: aqua;
            }


What I have tried:

here is my droup down menu css
CSS
.dropbtn {
    list-style-type: none;
    color: white;
    padding: 14px;
    font-size: 14px;
    border: none;
    cursor: pointer;
}

.dropdown {
    position: relative;
    display: block;
}

.dropdown-content {
    list-style-type: none;
    display: none;
    position: absolute;
    right: 0;
    /*background-color: black;*/
    background-image: url('../../Images/black-olive.jpg'); /*dropdowm popup*/
    min-width: 160px;
    box-shadow: 0px 8px 16px 5px rgba(0,0,0,0.2);
    z-index: 1;
    padding-right: 2px;
    margin-right: 2px;
}

    .dropdown-content a {
        color: white;
        padding: 10px 14px;
        text-decoration: none;
        display: block;
    }

        .dropdown-content a:hover {
            /*background-color: gray;*/
            color: black;
        }

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown:hover .dropbtn {
    /*background-color: #3e8e41;*/
}
Posted
Updated 12-Jul-17 23:07pm
Comments
j snooze 12-Jul-17 17:44pm    
looking at this might help you out
https://www.w3schools.com/howto/howto_css_dropdown.asp

1 solution

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#talltabs-maroon {
	/*clear: left;
    float: left;*/
	padding: 0;
	border-top: 3px solid #CD324F;/*width: 100%;
    overflow: hidden;
    font-family: Georgia, serif;
    height: 90px;
    position: inherit;*/
}
   #talltabs-maroon ul {
	float: left;
	margin: 0;
	padding: 0;
	list-style: none;
	position: relative;/*left: 50%;
        text-align: center;*/
}
   #talltabs-maroon ul a {
	display: block;
	color: #333;
	text-decoration: none;
	font-weight: 700;
	font-size: 12px;
	/*line-height:32px;*/
	padding: 0 15px;
}
#talltabs-maroon ul li {
	/*display: block;*/
	float: left;
	/*list-style: none;*/
	margin: 0;
	/*padding: 0;*/
	position: relative;
	/*right: 50%;*/
	padding: 0px 20px;
	list-style: none;
}
#talltabs-maroon ul li a {
	text-decoration: none;
}
   #talltabs-maroon ul li.current-menu-item {
	background: #ddd
}
#talltabs-maroon ul li:hover {
	background: #f6f6f6
}
#talltabs-maroon ul ul {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	background: #fff;
	padding: 0
}
#talltabs-maroon ul ul li {
	float: none;
	width: 100%;
	margin: 1px 0px;
	padding: 0px 5px;
}
#talltabs-maroon ul ul a {
	/*line-height:120%;*/
	padding: 5px
}
#talltabs-maroon ul ul ul {
	top: 0;
	left: 100%
}
#talltabs-maroon ul li:hover > ul {
	display: block
}
</style>
</head>

<body>
<div id="talltabs-maroon">
  <ul>
    <li class='@Html.IsActive("Home", "Index")'> <a href=@Url.Action("Index", "Home")> <span class="glyphicon glyphicon-random"></span> @**@
      <p>Analog<span> Signal</span></p>
      </a> </li>
    <li> <a href=@Url.Action("Index", "Home")> <span class="glyphicon glyphicon-signal"></span>
      <p>Digital <span>Signal</span></p>
      </a> </li>
    <li class='@Html.IsActive("Home", "SignalDataView")'> <a href=@Url.Action("SignalDataView", "Home")> <span class="glyphicon glyphicon-list"></span>
      <p>Signal Data View</p>
      </a> </li>
    <li class='@Html.IsActive("Home", "SignalDataReView")'> <a href=@Url.Action("SignalDataReView", "Home")> <span class="glyphicon glyphicon-search"></span>
      <p>Signal Data Review</p>
      </a> </li>
    <li class='@Html.IsActive("Home", "IOSignalList")'> <a href=@Url.Action("IOSignalList", "Home")> <span class="glyphicon glyphicon-stats"></span>
      <p>IO Status</p>
      </a> </li>
    <li class='@Html.IsActive("Home", "IOSignalList")'> <a href=@Url.Action("IOSignalList", "Home")> <span class="glyphicon glyphicon-list-alt"></span>
      <p>IO Signal List</p>
      </a> </li>
    <li class="dropdown @Html.IsActive("Certificate", "Index")"> <a href=@Url.Action("IOSignalList", "Home") class="dropbtn" style="margin-bottom:0px;"> <span class="glyphicon glyphicon-certificate"></span>
      <p> Certificates </p>
      </a>
      <ul class="dropdown-content">
        <li> <a href=@Url.Action("Valve", "Report")>
          <p style="margin: 0px;">Valve Report</p>
          </a> </li>
        <li> <a href=@Url.Action("Valve", "Report")>
          <p style="margin: 0px;">Cylinder Report</p>
          </a> </li>
      </ul>
    </li>
  </ul>
</div>
</body>
</html>
 
Share this answer
 

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