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>
Related
I have the topnav bar in the middle and when zooming out it stays there, but the picture(logo) and the tickets thing don't. Like you can see everythings is position relative. Also tried with margin auto, margin-left and margin-right auto but it just doesnt stay there. Also tried making the div just in the middle but that didn't work either. Every help is appreciated. :)
body{
margin: 0;
}
#header{
background-color: #a61b2b;
display: grid;
grid-template-columns: 20% 80%;
height: 120px;
align-content: center;
justify-content: flex-end
}
#topnav li{
margin: 0px 5px;
}
#topnav{
position: relative;
top: 40px;
right: 460px;
font-family: 'Open Sans',arial,sans-serif;
color: #f2f2f2;
padding: 14px 16px;
font-size: 12px;
font-weight: bold;
list-style: none;
display: flex;
margin: auto;
}
#topnav a:hover {
background-color: #eb0627;
}
#topnav a{
text-decoration:none;
color: #fff
}
#topnav li:hover ul{
display: block;
list-style: none;
background: black;
color: #fff;
padding: 10px;
position: absolute;
left: 0;
}
#topnav li ul li{
margin: 10px 0px;
}
#logo{
position: relative;
left: 500px;
width: 55%;
}
#tickets{
position: relative;
left: 450px;
background-color: black;
}
.hidden{
display:none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Granada Club de FĂștbol | Granada </title>
<link href="style.css" rel="stylesheet" type="text/css"/>
<script src="scripts.js"></script>
</head>
<body>
<div id="header">
<img alt="Logo" id="logo" src="https://i.ibb.co/gTqYynf/logo.png">
<ul id="topnav">
<li>NEWS
<ul class="hidden">
<li>CLUB
</li>
<li>FIRST TEAM
</li>
</ul>
</li>
<li>
THE CLUB
<ul class="hidden">
<li>CLUB INFORMATION
</li>
<li>STRUCTURE
</li>
</ul>
</li>
<li>
FIRST TEAM
<ul class="hidden">
<li>SQUAD </li>
<li>TRAINING</li>
</ul>
</li>
<li>TEAMS
<ul class="hidden">
<li>GRANADA B </li>
<li>GFC LADIES</li>
</ul>
</li>
<li>GRANADA TV
</li>
<li><a id="tickets" href="#">TICKETS</a>
</li>
</ul>
</div>
</body>
</html>
For everyone having a similiar problem, i found a solution. just make a second div tag under the header tag which has a fixed with and margin left and right auto. this makes a div tag in the middle which won't move.
Here's the code of how i fixed it.
body{
margin: 0;
}
a{
transition: all .25s;
}
#header{
background-color: #a61b2b;
display: flex;
grid-template-columns: 20% 80%;
height: 110px;
align-content: center;
justify-content: flex-end;
}
#h2{
width: 975px;
margin-left: auto;
margin-right: auto;
padding-top: 6px;
}
#topnav li{
margin: 0px 5px;
}
#topnav{
position: relative;
font-family: 'Open Sans',arial,sans-serif;
color: #f2f2f2;
padding: 14px 16px;
font-size: 12px;
font-weight: bold;
list-style: none;
display: flex;
margin: auto;
}
#topnav a:hover {
background-color: #eb0627;
}
#topnav a{
text-decoration:none;
color: #fff
}
#topnav li:hover ul{
display: block;
list-style: none;
background: black;
color: #fff;
padding: 10px;
position: absolute;
left: 0;
}
#topnav li ul li{
margin: 10px 0px;
}
#logo{
position: relative;
width: 20%;
}
#tickets{
position: relative;
left: 480px;
background-color: #343434;
padding: 8px;
}
#search{
position: relative;
top: -30px;
left: 650px;
width: 20px;
}
#fb{
padding-right: 5px;
width: 10px;
}
.hidden{
display:none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Granada Club de FĂștbol | Granada </title>
</head>
<body>
<div id="header">
<div id="h2">
<img alt="Logo" id="logo" src="https://i.ibb.co/gTqYynf/logo.png">
<img id="search" src="https://cdn.discordapp.com/attachments/629756354701295616/707198877857480744/search-icon.png">
<ul id="topnav">
<li>NEWS
<ul class="hidden">
<li>CLUB
</li>
<li>FIRST TEAM
</li>
</ul>
</li>
<li>
THE CLUB
<ul class="hidden">
<li>CLUB INFORMATION
</li>
<li>STRUCTURE
</li>
</ul>
</li>
<li>
FIRST TEAM
<ul class="hidden">
<li>SQUAD </li>
<li>TRAINING</li>
</ul>
</li>
<li>TEAMS
<ul class="hidden">
<li>GRANADA B </li>
<li>GFC LADIES</li>
</ul>
</li>
<li>GRANADA TV
</li>
<li><a id="tickets" href="#"><img id="fb" src="https://image.flaticon.com/icons/svg/27/27212.svg">TICKETS</a>
</li>
</ul>
</div>
</div>
</body>
</html>
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!
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>
I would like to have a long border underneath my menu UL, but the "border-bottom" property on the list items does not work well:
#headermenu {
height: 40px;
background: #f47a20;
position: relative;
}
#headermenu .menu {
background: #F47B20;
float: left;
border: 1px solid #D66C1C;
padding: 0.6em 1em;
margin-top: 0.5em;
list-style-type: none;
}
#headermenu-left {
padding: 0;
position: absolute;
top: 0;
left: 0;
width: 70%;
margin: 0;
}
#headermenu-left .menu {
border-bottom: 4px solid #004B8D;
}
<body>
<div id="headermenu">
<ul id="headermenu-left">
<li class="menu">
Link 1
</li>
<li class="menu">
Link 2
</li>
<li class="menu">
Link 3
</li>
<li class="menu">
Link 4
</li>
<li class="menu">
Link 5
</li>
<li class="menu">
Link 6
</li>
</ul>
</div>
</body>
The border is interrupted at the corners by -I guess- the border-left and border-right properties not being there?
I can't put it on the <ul> element, because then the line runs too long.
You can put it on the UL if you get rid of the width on it. Remove your last rule and use this:
#headermenu {
height: 40px;
background: #f47a20;
position: relative;
}
#headermenu .menu {
background: #F47B20;
float: left;
border: 1px solid #D66C1C;
padding: 0.6em 1em;
margin-top: 0.5em;
list-style-type: none;
}
#headermenu-left {
padding: 0;
position: absolute;
top: 0;
left: 0;
margin: 0;
border-bottom: 4px solid #004B8D;
}
<body>
<div id="headermenu">
<ul id="headermenu-left">
<li class="menu">
Link 1
</li>
<li class="menu">
Link 2
</li>
<li class="menu">
Link 3
</li>
<li class="menu">
Link 4
</li>
<li class="menu">
Link 5
</li>
<li class="menu">
Link 6
</li>
</ul>
</div>
</body>
The problem, as you suggest, is the missing left and right borders, which have a width, but no color, so this distorts the appearance of the bottom border with the illusion of a missing notch.
To solve this you can simply define border-width: 0 for the element, and allow the border-bottom property to override that setting.
#headermenu {
height: 40px;
background: #f47a20;
position: relative;
}
#headermenu .menu {
background: #F47B20;
float: left;
border: 1px solid #D66C1C;
padding: 0.6em 1em;
margin-top: 0.5em;
list-style-type: none;
}
#headermenu-left {
padding: 0;
position: absolute;
top: 0;
left: 0;
width: 70%;
margin: 0;
}
#headermenu-left .menu {
border-width: 0;
border-bottom: 4px solid #004B8D;
}
<body>
<div id="headermenu">
<ul id="headermenu-left">
<li class="menu">
Link 1
</li>
<li class="menu">
Link 2
</li>
<li class="menu">
Link 3
</li>
<li class="menu">
Link 4
</li>
<li class="menu">
Link 5
</li>
<li class="menu">
Link 6
</li>
</ul>
</div>
</body>
Unfortunately this is how borders work. Those are the ends of your border-left, and border-right. Here's a work around though, I added a div to the bottom of your list:
(I also removed your width:70%; from your list)
#bluebar {
position:absolute;
bottom:0px;
width:100%;
height:5px;
background-color:blue;
}
http://jsfiddle.net/BjGvp/6/
I'm trying to get a ul horizontally centered within the space but no matter what I try it remains left aligned.
<nav>
<div id="home">
<ul id="topnav">
<li class="home">home</li>
<li class="products">products</li>
<li class="support">support</li>
<li class="wtb">where to buy</li>
<li class="webstore">web store</li>
<li class="contact">contact us</li>
<li class="facebook"><a href="#" target="_blank"
title="Hauppauge Computer Works">facebook</a></li>
</ul>
</div>
</nav>
CSS:
CSS file here
ul#topnav {
padding: 0px;
list-style: none;
margin-right: auto;
margin-left: auto;
margin-top: 0px;
margin-bottom: 0px;
position: relative;
left: auto;
width: 123px;
}