CSS: Overlapping Unordered Vertical List - html

Please check out the following fiddle.
.sideNav {
width: 25%;
}
.sideNav ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 25%;
height: 100%;
position: fixed;
overflow: auto;
}
.sideNav li a {
display: block;
color: black;
text-align: center;
text-decoration: none;
}
.sideNav li {
font-family: "Comic Sans MS", cursive;
text-align: center;
float: left;
}
.right {
width: 75%;
}
<div class="content">
<div class="sideNav">
<ul>
<li>Curriculum
</li>
<li>ERSEA
</li>
<li>Family Services
</li>
<li>Mental Health
</li>
<li>Nutrition
</li>
<li>Health
</li>
<li>Policies & Procedures
</li>
<li>ERSEA
</li>
<li>Family Services
</li>
<li>Mental Health
</li>
<li>Nutrition
</li>
</ul>
</div>
<div class="right">
This is a test
</div>
</div>
I am having an issue with my CSS unordered list links. The links are not appearing on their own, separate lines. For instance, Link1 (Curriculum) is running into Link2 (ERSEA), so-on and so-forth. Also, I created two <div> tags, setting one to 25% of the div and the other to 75% of div. However, they are interfering with one another, as you can see from my fiddle, the "This is a test" text appears behind my unordered list.
I need my side navigation bar to be fixed in one position and have all of the links on their own separate lines. In addition, I need to have the "This is a test" text appear in its own separate portion of the site; to the right of the side navigation bar.

You have a couple of issues:
you have set your li:s to float: left, this will cause them to merge together.
you have set the .sideNav to have position: fixed, this means that it will not be calculated into the "flow" of the rest of the items on the site and therefore sit on top of them.
Here's a little updated css to help you along a little...
.sideNav {
width: 25%;
}
.sideNav ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 25%;
height: 100%;
position: fixed;
overflow: auto;
}
.sideNav li a {
display: block;
color: black;
text-align: center;
text-decoration: none;
}
.sideNav li {
font-family: "Comic Sans MS", cursive;
text-align: center;
display: block;
}
.right {
padding-left: 25%;
width: 75%;
}

Related

How to evenly stretch nav items ul li to the width of a container [duplicate]

This question already has an answer here:
Horizontal list items - fit to 100% with even spacing
(1 answer)
Closed 4 years ago.
I have a simple menu place in a container which has width as 100% but ul width is set to max-width: 1100px; leaving space on right side from the last element of menu.
How can i evenly stretch menu to the width of the container.
https://codepen.io/anon/pen/oqOGLL
.container{ width:100%; background-color: #f00;}
.mm-nav-wrap {
max-width: 1100px;
margin: 0 auto;
height:35px;
}
.mm-main-nav {
display: block;
width: 100%;
font-family: 'Open Sans', sans-serif;
font-size: 10px;
font-weight: 400;
background-color: green;
height:35px;
}
ul, ol {
padding: 0px;
}
ol, ul {
margin-top: 0;
margin-bottom: 10px;
}
.mm-main-nav li {
list-style-type: none;
display: inline;
float: left;
margin: 0;
padding: 0;
list-style: none;
line-height: normal;
}
.mm-main-nav li a {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 600;
display: block;
padding: 8px 13px 1px 13px;
text-decoration: none;
color: #111;
position: relative;
border-bottom: 5px solid transparent;
}
<div class="container">
<div class="mm-nav-wrap">
<ul class="mm-group mm-main-nav">
<li> HOME </li>
<li> ABOUT US </li>
<li> MENU ONE </li>
<li> MENU TWO </li>
<li> MENU THREE </li>
<li> FOUR </li>
<li> MENUFIVE </li>
<li> SIX </li>
<li> SEVEN </li>
<li> CONTACT US </li>
</ul>
</div>
</div>
You can achieve what you require in your design with display: table and display:table-cell properties. Try this code.
.mm-main-nav {
display: table;
table-layout: fixed;
}
.mm-main-nav li {
list-style-type: none;
display: table-cell;
margin: 0;
padding: 0;
list-style: none;
line-height: normal;
}
However, if you don't need all the menu items to be equal width, you can remove table-layout: fixed;

CSS/HTML Weird LI spacing

I have a HTML5 header setup. It uses <ul> and <li> elements for the links.
This is the HTML:
<header>
<nav>
<ul>
<li id="logoli"><img src="/assets/logo.png" id="logo"></li>
<li>Home</li>
<li class="5px">Roulette</li>
<li>Free Stuff</li>
</ul>
</nav>
</header>
And the CSS:
header {
height: 100%;
width: 100%;
}
nav {
width: 100%;
height: 65px;
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
padding-left: 10px;
background-color: rgba(0, 0, 0);
color: #0077C5;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
float: left;
}
li {
width: 100px;
line-height: 65px;
vertical-align: middle;
text-align: center;
margin: 0;
text-align: center;
display: inline;
list-style: none;
float: left;
}
#logo {
height: 50px;
}
#logoli {
padding-top: 7px;
width: 250px;
}
For some reason this happens: https://image.prntscr.com/image/w0LAMn5qRMq0OqIAfDTsHw.png
If you look at the nav bar you can easily see that the first two elements have a normal amount of spacing in-between. But the seccond and third have weirdly small spacing. I used inspect element on the <li>'s but they are all the same height. Can someone help me?
You need some HTML and CSS Fixes, Wrap the anchors in li elements and the issue was you have mentioned a width to the li, which causes this wierd spacing.
HTML
<header>
<nav>
<ul>
<li id="logoli">
<img src="/assets/logo.png" id="logo"></li>
<li>Home</li>
<li class="5px">Roulette</li>
<li>Free Stuff</li>
</ul>
</nav>
</header>
CSS
header {
height: 100%;
width: 100%;
}
nav {
width: 100%;
height: 65px;
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
padding-left: 10px;
background-color: rgba(0, 0, 0);
color: #0077C5;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
float: left;
}
li {
line-height: 65px;
vertical-align: middle;
text-align: center;
margin:0px 10px;
text-align: center;
display: inline;
list-style: none;
float: left;
}
#logo {
height: 50px;
}
#logoli {
padding-top: 7px;
width: 250px;
}
You should put the <a href>'s inside the <li> tags like this:
<header>
<nav>
<ul>
<li id="logoli"><img src="/assets/logo.png" id="logo"></li>
<li>Home</li>
<li>Roulette</li>
<li>Free Stuff</li>
</ul>
</nav>
</header>
Also - you have a class="5px" on one of the <li>'s, but that class isn't in your CSS. You should make your <li>'s a fixed width and center the text, or use a standard padding on the left and right of the <li> text to maintain a uniform spacing rather than injecting classes to push single elements around.
This is happening because you're explicitly defining a width on your list items. Remove the width and separate the list items with padding instead. Optionally, remove any padding on the last list item, since you won't need it.
li {
/* width: 100px; */
padding-right: 1em;
line-height: 65px;
vertical-align: middle;
text-align: center;
margin: 0;
text-align: center;
display: inline;
list-style: none;
float: left;
}
li:last-child {
padding-right: 0;
}
https://jsfiddle.net/eulloa/yx7vkt79/
Also, restructure your list items so that they are the parent element of your anchors, not the other way around.
<li>Home</li> <!-- structure your list items this way -->
<li>Home</li>

Space between navigation bar and screen [duplicate]

This question already has answers here:
Width 100% with white borders around it. WHy?
(2 answers)
Closed 5 years ago.
I faced an issue today when I created the navigation bar I found a space between the screen and the navigation bar,
here's what I'm talking about
I want the navigation bar with full width, no space at all, I tried using width width: 100% but it didn't work.
Here's the code :
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #141414;
height: 80px;
border-radius: 5px;
}
li {
float: right;
display:inline;
list-style-type:none;
}
li a {
font-family: Julius Sans One, Arial;
font-size: 19px;
display: block;
color: white;
text-align: center;
padding: 30px 20px;
text-decoration: none;
}
.logoimg {
height: auto;
margin-left: 150px;
margin-top: 5px;
}
.left {
float: left;
}
<div>
<ul>
<li class="left"><img class="logoimg" src="/images/logo.png"></li>
<li><a>Test 1</a></li>
<li><a>Test 2</a></li>
</ul>
</div>
From the look of it, your navigation bar is full-width. The additional whitespace you are seeing is actually coming from <body>, which adds a margin of 8px by default. You can override this to ensure that your content is flush against the edge of the page:
body {
margin: 0; /* Added */
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #141414;
height: 80px;
border-radius: 5px;
}
li {
float: right;
display:inline;
list-style-type:none;
}
li a {
font-family: Julius Sans One, Arial;
font-size: 19px;
display: block;
color: white;
text-align: center;
padding: 30px 20px;
text-decoration: none;
}
.logoimg {
height: auto;
margin-left: 150px;
margin-top: 5px;
}
.left {
float: left;
}
<div>
<ul>
<li class="left"><img class="logoimg" src="/images/logo.png"></li>
<li><a>Test 1</a></li>
<li><a>Test 2</a></li>
</ul>
</div>
It's important to note that the <body> tag is always present, even when not explicitly written. This can be seen in the snippets here -- note that the original snippet appears to be offset from the edge and the line, whereas this does not, and all I added was an override for body margin.
Hope this helps! :)
What you are experiencing is the default window/page Padding/Margin. You can set this default value to 0 in order to have your full width/height of the page:
body{
margin: 0;
padding: 0;
}
This should correct your problem.

UI/UX with two div each contain menu

I want to achieve some UI/UX like this
so there is a logo, also 2 menu, 1 for language change, 1 for change menu
my approach is two div
first div contain image and language menu ul
second div contain menu ul
but, image in first div is covered by second div
did my approach wrong?
Here is what I've done
HTML & CSS
header {
position: fixed;
}
#logo {
position: fixed;
float: left;
}
#nav-language {
align: right;
width: 100%;
height: 66px;
}
#nav-menu {
background-color: #ccb96b;
width: 100%;
height: 66px;
top: 67px;
position: fixed;
}
#nav-menu ul {
left: 500px;
z-index: 5;
}
ul {
list-style-type: none;
}
li {
display: inline;
padding: 15px;
}
#nav-language a {
font-size: 1.6em;
text-transform: uppercase;
font-weight: bold;
font-family: century gothic;
text-decoration: none;
color: white;
}
#nav-menu a {
font-size: 1.6em;
text-transform: uppercase;
font-weight: bold;
font-family: century gothic;
text-decoration: none;
color: #430615;
}
#nav-menu a:hover {
opacity: 0.36;
}
<header>
<div id='nav-language'>
<img id="logo" src="<?php echo base_url(); ?>assets/images/logo.png" />
<ul>
<li class='navigation-Blog'><a href='#'>en</a></li>
<li class='navigation-Crew'><a href='#'>fr</a></li>
<li class='navigation-Promos'><a href='#'>it</a></li>
</ul>
</div>
<div id='nav-menu'>
<ul>
<li class='navigation-Blog'><a href='#'>home</a></li>
<li class='navigation-Crew'><a href='#'>About Us</a></li>
<li class='navigation-Promos'><a href='#'>contact us</a></li>
</ul>
</div>
</header>
any help appreciated, maybe my approach could be wrong, welcome for advice
I was able to achieve what you're looking for by changing the #nav-language to position: relative; and changing the css on the #logo div's z-index and top & bottom attributes. Here's a jsfiddle
EDIT: Note that you'll have to play with the top and bottom values depending on your image size, i've used a random image as an example
EDIT2: i noticed that you have align: right; on your #nav-language div, but align doesn't exist in css, you'll want to set the header width to 100% and put float: right; on the language ul. i've updated my jsfiddle with the correct css
https://jsfiddle.net/n42dyhza/2/

How to change size of Nav bar

All the questions I've looked at refer to WordPress or Bootstrap (what is that?) nav bars, I have made mine using CSS.
I would like to make my nav bar bigger so that it's easier for mobile users to click the correct link. I've tried using the height: px; but all that did was push the text below further down.
What do I use to change the size of the buttons themselves? included my CSS below.
html{background:gray;}
ul {
left: 0;
top: 50%;
width: 100%;
text-align: center;
display: inline-block;
list-style-type: none;
}
li {
display: inline-block;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
margin: 0
}
li a:hover:not(.active) {
background-color: #111;
}
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
Please note I have added backgrounds in order to display the navbar, and are not required in production
You are OK to use the ul and li elements within your code. In order to make the navbar appear 'taller', you would need to set both the height of the ul element itself, as well as the child li. A quick demo has been provided below.
I have given the height of the ul element 100px, although this value can be changed to your preference. Note you may also want to change line-height property of your a elements to suit this.
html,body {
background: gray;
margin:0;
padding:0;
}
ul {
left: 0;
top: 50%;
text-align: center;
display: block;
list-style-type: none;
background: dimgray;
height: 100px; /* <-- change this line*/
}
li {
display: inline-block;
height: 100%;
}
li a {
display: inline-block;
color: white;
background: lightgray;
line-height: 100px; /* <-- change this line*/
text-align: center;
padding-left: 50px;
padding-right: 50px;
text-decoration: none;
margin: 0;
height: 100%;
}
li a:hover:not(.active) {
background-color: #111;
}
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
What do I use to change the size of the buttons themselves?
Add more padding! Take a look-see.
body {background-color: gray;}
ul {
left: 0;
top: 50%;
width: 100%;
text-align: center;
display: inline-block;
list-style-type: none;
}
li {
display: inline-block;
}
li a {
display: block;
color: white;
text-align: center;
padding: 2em; /* bigger button? add more padding! */
text-decoration: none;
margin: 0
}
li a:hover:not(.active) {
background-color: #111;
}
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
There are many ways to increase the size of the link. This is just one way. jbutler's answer is a good way too. It just depends on what exactly you want it to do.
Hope this helps.
If you are trying to make the text itself larger you can use the font-size property.