EDIT: Seeing as two people have misunderstood what i'm going for - i'll make it perfectly clear: I'm looking for a DROP UP menu from a footer, not a DROP DOWN menu from a header.
This crap has been bugging me for like a week now.
http://jsfiddle.net/pwg24xbf/1/
I need to make the hidden lists as a drop up menu.
I need them to be positioned, percentagewise to the container (BCONT), which means i cannot "position: absolute" and use percentages.
At this point I don't know what to do. Really need help!
In conclusion: What I need is a drop up menu to the list within BCONT. I need ALL sizes, positions and so on in %. NOT IN PX.
Furthermore I need the list VERTICALLY CENTERED within BCONT aswell.
<div id="BCONT">
<ul>
<li>CHAT<i id="CABUP" class="fa fa-comment"></i></li>
<li>LANGUAGE<i id="LGBUP" class="fa fa-chevron-up"></i>
<ul id="LGBMENU">
<li>sub1</li>
<li>sub2</li>
</ul>
</li>
<li>SERVICES<i id="SVBUP" class="fa fa-chevron-up"></i>
<ul id="SVGMENU">
<li>sub1</li>
<li>sub2</li>
</ul>
</li>
<li style="padding-right:12px;">HELP<i id="HPBUP" class="fa fa-chevron-up"></i>
<ul id="HPBMENU">
<li>sub1</li>
<li>sub2</li>
</ul>
</li>
</ul>
</div>
#BCONT {
width: 100%;
height: 4.125%;
background-color: #6779e8;
position: fixed;
bottom: 0px;
font-family:my_fat_font;
overflow: auto;
}
#BCONT ul li {
display: inline-block;
margin-right: 6px;
margin-left: 6px;
padding-right: 6px;
padding-left: 6px;
color:white;
height: 100%;
}
#BCONT ul {
margin: 0px;
height: 100%;
float: right;
vertical-align:middle;
}
#BCONT:after, {
vertical-align:middle;
}
#BCONT ul li ul {
display: none;
}
#LGBUP, #SVBUP, #HPBUP, #CABUP {
font-size: 20px;
padding-left: 7px;
}
This is the best I could do. Sorry if this wasn't what you wanted.
http://jsfiddle.net/pwg24xbf/6/
.outerdiv{
position:relative;
}
#BCONT {
width: 100%;
height: 7.125%;
background-color: #6779e8;
font-family:my_fat_font;
overflow: hidden;
}
#BCONT .outer-ul>li {
display: block;
float:left;
margin-right: 6px;
margin-left: 6px;
padding-right: 6px;
padding-left: 6px;
color:white;
height: 100%;
}
#BCONT ul {
margin: 0px;
height: 172%;
float: left;
vertical-align:middle;
}
#BCONT:after, {
vertical-align:middle;
}
#LGBUP, #SVBUP, #HPBUP, #CABUP {
font-size: 20px;
padding-left: 7px;
}
.inner-ul > li{
display:block;
}
.inner-ul{
z-index: 9999;
position: absolute;
display: none;
background-color:black;
}
#LGBMENU,#SVGMENU,#HPBMENU{
float:none !important;
}
.outer-ul>li:hover > .inner-ul{
display:block;
}
HTML -
<div class="outerdiv">
<div id="BCONT">
<ul class="outer-ul">
<li>CHAT<i id="CABUP" class="fa fa-comment"></i></li>
<li>LANGUAGE<i id="LGBUP" class="fa fa-chevron-up"></i>
<ul class="inner-ul" id="LGBMENU">
<li>sub1</li>
<li>sub2</li>
</ul>
</li>
<li>SERVICES<i id="SVBUP" class="fa fa-chevron-up"></i>
<ul class="inner-ul" id="SVGMENU">
<li>sub1</li>
<li>sub2</li>
</ul>
</li>
<li style="padding-right:12px;">HELP<i id="HPBUP" class="fa fa-chevron-up"></i>
<ul class="inner-ul" id="HPBMENU">
<li>sub1</li>
<li>sub2</li>
</ul>
</li>
</ul>
</div>
</div>
Related
I'm having trouble aligning my drop down menu in my nav bar, I've tried every suggestion out there. I've tried left, float: left, right, and pretty much everything else. I think it is possibly something interfering. The drop down menu has everything aligned from center to right of the parent menu item.
https://jsfiddle.net/ethacker/j7tgq95j/3/
My html code:
<header>
<nav>
<h1> Welcome to Mommy Madness</h1>
<ul>
<li class="parentMenu">Home
<ul class="sub-menu">
<li>About</li>
<li>Contact</li>
</ul>
</li>
<li class="parentMenu">Pregnancy
<!--
Gender Predictions:
Old Wive's Tale
Boy vs Girl- The Ramzi Method
-->
<ul class="sub-menu">
<li>Advice</li>
<li>Gender Predictions</li>
<li>Trying To Conceive</li>
</ul>
</li>
<li class="parentMenu">All About Baby
<ul class="sub-menu">
<li>Fetal Development</li>
<li>Guidelines </li>
<li> Milestones</li>
</ul>
</li>
<li class="parentMenu">Party Momma
<!--
Birthdays - Link to 1-10th bdays.
-->
<ul class="sub-menu">
<li>Pregnancy Announcement</li>
<li>Gender Reveal</li>
<li>Baby Shower</li>
<li>Birth Announcement</li>
<li> Birthdays</li>
</ul>
</li>
<li class="parentMenu">Stations
<ul class="sub-menu">
<li>Hospital Bag</li>
<li>Diaper Bag</li>
<li>Changing Station</li>
<li>Baby Gear</li>
</ul>
</li>
<li class="parentMenu">Memory Markers
<!--
Drop Down Menu:
DIY
Purchases
(Both to have holiday/event selectors on right of page)
-->
<ul class="sub-menu">
<li>DIY</li>
<li>Purchases</li>
</ul>
</li>
<li class="parentMenu">Reviews
<ul class="sub-menu">
<li>Games</li>
<li>Gear</li>
<li>Learning</li>
</ul>
</li>
<li class="parentMenu">Blog
<ul class="sub-menu">
<li>Fit Momma</li>
<li>Minimal Momma</li>
<li>Modern Momma</li>
<li>Organic Momma</li>
<li>Organizing Queen</li>
<li>Savings Savvy</li>
<li>Tech Savvy</li>
<li>Traditional Momma</li>
</ul>
</li>
</ul>
</nav>
My css code:
body {
background-color: beige;
color: lightblue;
padding: 0;
margin:0;
}
header {
background-color: lightblue;
padding: 5px 0;
margin: 0;
}
header h1 {
color: cadetblue;
font-family: Arial;
margin: 0;
padding: 5px 15px;
display: inline;
}
.navMenu{
display: inline;
margin: 0;
}
.navMenu .parentMenu {
display: inline-block;
list-style-type: none;
background-color: lightgray;
padding: 5px 10px;
border: thin solid darkgray;
border-radius: 3px;
color: honeydew;
position: relative;
margin: 0;
}
.navMenu .parentMenu a{
color: azure;
}
.navMenu .parentMenu .sub-menu{
display: none;
}
.navMenu .parentMenu:hover .sub-menu{
display: block;
position: absolute;
list-style-type: none;
margin:0;
}
.parentMenu:hover .sub-menu li{
border: thin solid darkgray;
padding: 4%;
background-color: lightgray;
color: honeydew;
text-align: left;
white-space: nowrap;
width: 100%;
list-style-type: none;
margin: 0;
}
.parentMenu .sub-menu li:hover {
background-color: lightsteelblue;
}
.section {
background-color: wheat;
color: darkslategray;
padding: 5px;
float: left;
display: inline;
width: 63%;
margin: 0 1% 1% 1%;
border-radius: 10px;
border: thin solid khaki;
box-shadow: lightgray;
}
#about {
float: right;
width: 30%;
margin: 1% 1% 0 0;
text-align: center;
}
#home{
margin: 1% 0 1% 1%;
}
h4, h3 {
color: lightseagreen;
}
This will align the submenu to the left:
.navMenu .parentMenu .sub-menu {
display: none;
position:absolute;
list-style-type: none;
padding:0;
margin: 0;
left:-1px;
top:27px;
}
.navMenu .parentMenu:hover .sub-menu {
display: block;
}
https://jsfiddle.net/am13qur4/
you did not specify where you want to align your drop down elements. Do you want to align all to the right, center or left. I assumed left so try adding the code below. You may need to adjust the left attribute's value and your hover background styling too.
.sub-menu a{
position: absolute;
left: 3%;
}
Let me know if this helps. Stay warm!
Im trying to have a menu where I have some links floated at left and then I have a div with some links that I want floated at right.
I'm trying to do this with the code below and it is working, but the left links and right links are no aligned at the center of the menu in terms of height, do you know why?
And also the :hover effect is not occupying the entire height of the menu.
CODE:
.container {
width: 100%;
background: yellow;
float: left;
}
.content {
height: 50px;
}
.menu-list {
list-style: none;
}
.menu-list li {
float: left;
}
.menu-links {
float: right;
}
.menu-list li a {
color: #aaa;
text-decoration: none;
line-height: 50px;
font-weight: bold;
}
.menu-list li a:hover {
background: red;
}
<div class="container">
<div class="content">
<ul class="menu-list">
<li><a title="" href="">Home</a>
</li>
<li><a title="" href="">Home</a>
</li>
<li><a title="" href="">Home</a>
</li>
<li><a title="" href="">Home</a>
</li>
<li><a title="" href="">Home</a>
</li>
<li><a title="" href="">Home</a>
</li>
<li><a title="" href="">Home</a>
</li>
</ul>
<div class="menu-links">
Link 1
Link 2
</div>
</div>
</div>
JsFiddle
Check this fiddle here
It happens because, you have used menu-list with ul and menu-links with div.
In basic HTML, ul has predefined padding and margin. So, first of all clear out that padding and margin then style menu-list and menu-links accordingly.
Instead of adding extra space or element use following html,
<div class="container">
<div class="content">
<ul class="menu-list">
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
</ul>
<ul class="menu-links">
<li>Link 1</li>
<li>Link 2</li>
</ul>
</div>
</div>
And your respective CSS will be,
body {
padding: 0;
margin: 0
}
.container {
display: block;
width: 100%;
background: yellow;
clear: both;
padding: 10px;
}
.container:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
a {
text-decoration: none
}
.menu-list,
.menu-links {
list-style: none;
margin: 0;
padding: 0
}
.menu-list {
float: left
}
.menu-links {
float: right
}
.menu-list li,
.menu-links li {
display: inline-block
}
Try this one
.container{
width:100%;
background:yellow;
float:left;
}
.content{
height: 50px;
}
.menu-list{
list-style:none;
margin: 0;
float: left;
}
.menu-list li{
display: inline-block;
}
.menu-links{
float: right;
}
.menu-links a{
line-height: 50px;
}
.menu-list li a{
color:#aaa;
text-decoration: none;
line-height: 50px;
font-weight: bold;
}
.menu-list li a:hover{
background:red;
padding: 16px 0px;
}
<div class="container">
<div class="content">
<ul class="menu-list">
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
<li><a title="" href="">Home</a></li>
</ul>
<div class="menu-links">
Link 1
<a href="" >Link 2</a>
</div>
</div>
</div>
How about this fiddle?
It is generally better to float the ul and give the li display: inline;
ul also has a default margin and padding on it so you need to use a reset of some sort
ul.menu-list{
margin: 0 0 0 15px;
padding: 0;
}
*Revised to make CSS only
Would something like this work? You just need to know the height of your nav bar, and add a pseudo-element of that height to each of the separate nav sections. https://jsfiddle.net/will0220/wg7hwc7s/
Just set them to display: inline-block and vertical-align: middle to keep them centered in the height of your nav bar by comparing it to the pseudo element. This should work with any number of lines of text in each button.
.container{
width:100%;
background:yellow;
float:left;
}
.menu-list{
list-style:none;
}
.menu-list{
float: left;
padding: 0;
margin: 0;
}
.menu-links{
float: right;
}
.menu-list li a{
color:#aaa;
text-decoration: none;
line-height: 50px;
font-weight: bold;
}
.menu-list:before, .menu-links:before{
content: '';
display: inline-block;
vertical-align: middle;
height: 50px;
width: 0;
}
.menu-list li, .menu-links a{
display: inline-block;
vertical-align: middle;
}
.menu-list li a:hover{
background:red;
}
You can use display:table-cell property to easily do that and also you don't have to use float for li to display as horizontal menu instead use display:inline
updated fiddle here
How can I align the down arrow from material icons under the link text? I tried using the :after pseudo class, but it didn't work.
HTML:
<div class="jump-to-links">
<ul class="list-unstyled">
<li>
Link<i class="material-icons"></i>
</li>
<li>
Link<i class="material-icons"></i>
</li>
<li>
Link<i class="material-icons"></i>
</li>
<li>
Link<i class="material-icons"></i></li>
</ul>
</div>
SCSS:
.jump-to-links {
.material-icons {
#include centerX();
bottom: -20px;
color: $purple;
padding: 10px 0px 10px 0px;
}
text-align: center;
a,a:hover {
text-decoration: none;
color: $black;
font-weight: bold;
display: inline-block;
}
ul li {
display: inline-block;
margin-right: 12%;
}
li {
cursor: pointer;
text-align: center;
position: relative;
}
}
JSFIDDLE https://jsfiddle.net/kpvwwveL/6/
Add display:block to your
i{
display:block;
}
https://jsfiddle.net/kpvwwveL/3/
I discovered this as the best way to solve the alignment issue:
<div class="jump-to-links">
<ul class="list-unstyled">
<li>
Link<i class="material-icons"></i>
</li>
<li>
Link<i class="material-icons"></i>
</li>
<li>
Link<i class="material-icons"></i>
</li>
<li>
Link<i class="material-icons"></i></li>
</ul>
</div>
.jump-to-links {
.material-icons {
#include centerX();
bottom: -20px;
color: $purple;
padding: 10px 0px 10px 0px;
}
text-align: center;
a,a:hover {
text-decoration: none;
color: $black;
font-weight: bold;
display: inline-block;
}
ul li {
display: inline-block;
margin-right: 12%;
}
li {
cursor: pointer;
text-align: center;
position: relative;
}
}
Why complicate things and not go the natural way? Which I think is to put line breaks between link text and i.
<a href="#">
Link
<br>
<i class="material-icons arrow-down">keyboard_arrow_down</i>
</a>
https://jsfiddle.net/weejoy22/
When the browser page is full size, the menu is centered in the middle page (That's the correct position) but when resizing the window, the menu isn't visible anymore except by scrolling to the max right of the site. I looked it up to be a responsiveness problem, however i failed to solve it. Any ideas??
HTML:
<div id="menu" class="menu">
<ul class="headlines">
<li id="item1"onclick="checklist(this)"><button onclick="myFunction()">AA</button></li>
<li id="item2"><button onclick="myFunction2()">A </button></li>
<li id="item3">B </li>
<li id="item4">C </li>
<li id="item5">D </li>
<li id="item6">E </li>
<li id="item7">F </li>
</ul>
</div>
css:
lu, li{
list-style-type: none;
font-size: 1.5em;
height: 40px;
width: 150px;
text-align: right;
border-style: none;
}
.menu{
width:150px;
height: 350px;
}
.menu li{
position: relative;
top:150px;
bottom: 0;
left: 725px;
right: 0;
margin: auto;
border-style:none;
}
Add margin:0 auto; in .menu
Remove left: 725px; from .menu li
See Fiddle: https://jsfiddle.net/sachinkk/61capLqy/
lu, li{
list-style-type: none;
font-size: 1.5em;
height: 40px;
width: 150px;
text-align: right;
border-style: none;
}
.menu{
width:150px;
height: 350px;
margin:0 auto;
}
.menu li{
position: relative;
top:150px;
bottom: 0;
right: 0;
margin: auto;
border-style:none;
}
<div id="menu" class="menu">
<ul class="headlines">
<li id="item1"onclick="checklist(this)"><button onclick="myFunction()">AA</button></li>
<li id="item2"><button onclick="myFunction2()">A </button></li>
<li id="item3">B </li>
<li id="item4">C </li>
<li id="item5">D </li>
<li id="item6">E </li>
<li id="item7">F </li>
</ul>
</div>
I have a drop down nav menu that I need to be centered within a div but text-align: center isn't working for me.
The site is at http://www.joekellywebdesign.com/churchsample1/index.html
HTML
<div id="navmenudiv">
<ul id="navmenu">
<li>Home</li>
<li>
About Us
<ul class="sub1">
<li>Introduction</li>
<li>Who We Are</li>
<li>Staff</li>
</ul>
</li>
<li>
Services
<ul class="sub1">
<li>Sunday Morning</li>
<li>Sunday Evening</li>
<li>Wednesday Evening</li>
</ul>
</li>
<li>Resources</li>
<li>Contact Us</li>
<li>News and Events</li>
</ul>
</div>
CSS
navmenudiv {
z-index:60;
margin: -30px 0;
height:50px;
background-color:#5340BF;
top:40;position:
relative;
text-align:center;
}
Here is an easy solution:
ul#navmenu li {
float:left; /* REMOVE */
display: inline-block; /* ADD */
}
Currently, the li are floating. By changing them to inline-block elements, they will center - given that you are already using text-align:center on the parent.
Updated CSS:
ul#navmenu li {
margin-right: 4px;
text-align: center;
width: 125px;
display: inline-block;
position: relative;
}
ul#navmenu li {
width: 125px;
text-align: center;
position: relative;
margin-right: 4px;
display: inline-block;
margin: 0 10px;
}