I've never had a problem so hard as this, I can't even get started so I don't have a very good fiddle to show you, only the source code and what I'm trying to achieve.
I need a three level UL. The top level being inline - for top level navigation. The sub UL's and LI's will be inline-block - more or less.
Here's an image of what I mean: http://www.smileycat.com/miaow/archives/images/megamenus/ea.gif
I need something similar to this, kind of like a mega drop down I suppose? Can anyone help or point me in the right direction?
JSFiddle: http://jsfiddle.net/RVQ6m/
Some code:
<ul class="level1">
<li class="level1">top
<ul class="level2">
<li class="level2">middle
<ul class="level3">
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
</ul>
</li class="level2">
<li class="level2">middle
<ul class="level3">
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
</ul>
</li class="level2">
<li class="level2">middle
<ul class="level3">
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
</ul>
</li class="level2">
<li class="level2">middle
<ul class="level3">
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
<li class="level3">bottom</li>
</ul>
</li>
</ul>
</li>
</ul>
Well,
for one I think your doing this all wrong and you need to look at it a different way. From the image example you provided this seems more like a div showing and hiding content as apposed to a bunch of nested Unordered list. Also, I'm not sure what script you would like to use in order to achieve the effect you are looking for. For simplicity sake. I started you off by creating a Div that you can show and hide using JavaScript or a library of your choice. All you need to do now is find a script that will toggle (show and hide the div on mouseover) Note: the Div #games-display should not be displayed when a user lands on the page.
http://jsfiddle.net/jimmyt1001/Bz9QA/
First Your CSS
<style type="text/css">
.nav-container {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.8em;
}
div.column {
border-left: 2px #dedede solid;
width:156px;
float:left;
padding: 11px 25px 5px 11px;
}
div.column:nth-child(1)
{
border-left:none;
}
.column a {
line-height:1.7em;
}
ul {
color:#3173d4;
}
.column.highlight a {
color:#3173d4;
font-weight:bold;
}
.clear-fix {
clear:both;
}
#games-display {
width:580px;
height:273px;
border-top: 6px #639df4 solid;
border-right: 1px #639df4 solid;
border-left: 1px #639df4 solid;
border-bottom: 1px #639df4 solid;
background-color:#fff;
-webkit-border-bottom-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomleft: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
padding:10px;
}
.display-header {
width:135px;
height:5px;
background-color:#f7f7f7;
font-weight:bold;
padding:8px 5px 15px 15px;
border: 1px #c5c5c5 solid;
}
.featured {
width:135px;
height:125px;
background-color:#f7f7f7;
text-align:center;
font-weight:bold;
padding:12px;
border: 1px #c5c5c5 solid;
}
</style>
And then your HTML
<div class="nav-container">
Nav Link
<div id="games-display">
<div class="column highlight">
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
<div class="featured">
Featured Info
</div>
</div>
<div class="column">
<div class="display-header">Column 2</div>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
<li>Link 6</li>
<li>Link 7</li>
<li>Link 8</li>
</ul>
</div>
<div class="column">
<div class="display-header">Column 3</div>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
<li>Link 6</li>
<li>Link 7</li>
<li>Link 8</li>
</ul>
</div>
<div class="clear-fix"></div> <!-- Very dirty way of removing float property -->
</div>
</div>
Related
I'm trying to make a website footer inspired by the w3schools 4 column footer, however, the text in the li tags go off to the right a little (compared to the headings).
CSS:
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 100px;
}
footer {
position: absolute;
left: 0;
bottom: 0;
height: 100px;
width: 100%;
}
#footer {
width: 100%;
margin: auto;
}
.footerFloat {
width: 100%;
}
#media all and (min-width: 950px) {
#footer {
width: 980px;
margin: auto;
}
.footerFloat {
width: 25%;
float: left;
display: block;
}
}
#wrapper {
width: 100%;
overflow: hidden;
}
ul {
list-style: none;
}
.center {
text-align: center;
}
HTML:
<header></header>
<footer>
<div id="wrapper">
<div id="footer">
<div class="footerFloat">
<h4 class="center">Header 1</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
<div class="footerFloat">
<h4 class="center">Header 4</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
<div class="footerFloat">
<h4 class="center">Header 3</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
<div class="footerFloat">
<h4 class="center">Header 4</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
</div>
</div>
</footer>
Here is a picture of the problem.
Does anyone know how I could fix this, and centre the text with the headings in the footer?
Any help would be greatly appreciated, thanks.
—ItzJavaCraft
Remove the padding which is built into the ul by default.
.footerFloat {
width: 25%;
float: left;
}
#wrapper {
width: 100%;
overflow: hidden;
}
ul {
list-style: none;
padding: 0; /* here---add this */
}
.center {
text-align: center;
}
<footer>
<div id="wrapper">
<div id="footer">
<div class="footerFloat">
<h4 class="center">Header 1</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
<div class="footerFloat">
<h4 class="center">Header 4</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
<div class="footerFloat">
<h4 class="center">Header 3</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
<div class="footerFloat">
<h4 class="center">Header 4</h4>
<ul>
<li class="center">Line 1</li>
<li class="center">Line 2</li>
<li class="center">Line 3</li>
<li class="center">Line 4</li>
</ul>
</div>
</div>
</div>
</footer>
I have a footer with 7 links which i am centering on desktop. On mobile i would like these links to stack one on top of the other centered in one column, however they currently show inline in 2 rows of 3 columns and 1 now of 1.
HTML
<div class="col-md-12 pad-top text-center">
<ul class="footer-links">
<li>LINK 1</li>
<li>LINK 2</li>
<li>LINK 3</li>
<li>LINK 4</li>
<li>LINK 5</li>
<li>LINK 6</li>
<li>LINK 7</li>
</ul>
</div>
CSS
.footer-links {
color:#ffffff;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display:inline-block;
font-family: HelveticaNeu;
}
For example you can add class to the footer that will hide it, when user will watch from mobile device. And then unhide two columns with two lists.
Maybe it's a bit clumsy solution, but it is also a relatively good solution ;)
HTML
<div class="col-lg-12 col-md-12 pad-top text-center hideBlock">
<ul class="footer-links">
<li>LINK 1</li>
<li>LINK 2</li>
<li>LINK 3</li>
<li>LINK 4</li>
<li>LINK 5</li>
<li>LINK 6</li>
<li>LINK 7</li>
</ul>
</div>
<div class="col-xs-6 pad-top text-center unhideBlock">
<ul class="footer-links">
<li>LINK 1</li>
<li>LINK 2</li>
<li>LINK 3</li>
</ul>
</div>
<div class="col-xs-6 pad-top text-center unhideBlock">
<ul class="footer-links">
<li>LINK 4</li>
<li>LINK 5</li>
<li>LINK 6</li>
<li>LINK 7</li>
</ul>
</div>
CSS
#media (min-width: 768px){
.hideBlock {
display: block;
}
.unhideBlock {
display: none;
}
}
#media (max-width: 768px){
.hideBlock {
display: none;
}
.unhideBlock {
display: block;
}
}
But if you only need to break list into columns here is the useful >>> link
Per your comment yesterday, you've noted you want to have two columns on desktops/tablets, but one column on mobile and smaller widths.
This is fairly easy to achieve, you simply need to split the links into two separate divs.
.footer-links {
color: #ffffff;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display: inline-block;
font-family: HelveticaNeu;
}
.footer-links li:not(:last-child) {
padding-bottom: 4px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-sm-6 pad-top text-center">
<ul class="footer-links">
<li>LINK 1
</li>
<li>LINK 2
</li>
<li>LINK 3
</li>
<li>LINK 4
</li>
</ul>
</div>
<div class="col-sm-6 pad-top text-center">
<ul class="footer-links">
<li>LINK 5
</li>
<li>LINK 6
</li>
<li>LINK 7
</li>
</ul>
</div>
When you run the above snippet, you'll note that all the links are arranged in a single column. When you click to run the snippet in full screen, they'll expand out to be two columns.
I also added some CSS for the line items in the unordered list to add padding to the bottom of all li tags except for the last one to account for the odd spacing you get when in a mobile view. You can play around with that to suit your needs.
While you still haven't indicated how many links you would like in each column, this should get you started.
This is how I'm displaying a nested list jsFiddle. As you can see the 'columns' are not aligned correctly as the content has different length. The elements - as example - should be at the right border.
Is it possible to get the width of each 'column' in a relative or fixed size? The complete list should have a 100% width.
Visibly I want to get this: https://jsfiddle.net/bsrms9ax/2/
ul {
display: inline-table;
border: 1px solid #000;
padding: 0px;
list-style: none;
}
<ul>
<li>Main Title
<ul>
<li>Title 1
<ul>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
</li>
<li>Longer Main Title
<ul>
<li>Long Title 1
<ul>
<li>Element 1</li>
<li>Elem 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
</li>
</ul>
I edited the code from Display nested list like a table , also a post by you.
If this is not you want, i will do as much i can to modify it and make it work.
// ADD SOME CODE
// www.Agary.info Agario server ;-)
// BEST LUCK IN YOUR CODE BRO
body>ul {
display:table;
}
li {
display: flex;
display: -webkit-inline-flex;
border: 1px solid #000;
padding: 0px;
list-style: none;
}
<html>
<!-- Added some css..-->
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
</head>
<body>
<ul>
<li>Main Title
<ul>
<li>Title 1
<ul>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
<li>
</li>
<li>Main Title
<ul>
<li>Title 1
<ul>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>
EDIT: I see that this is not what you want, but maybe will be useful for any other user. I will try to modify it :)
I have a dropdown menu with a sub-menu, made up of lists:
<ul>
<li class="list_item">Item 1</li>
<li class="list_item">Item 2</li>
<ul>
<li class="sub_list_item">Sub Item 1</li>
<li class="sub_list_item">Sub Item 2</li>
</ul>
<li class="list_item">Item 3</li>
</ul>
My CSS changes the background-color of these items when hovered on.
What I want to do is keep Item 2's background color changed whilst hovering over any give Sub Item
Any simple way to do this?
CSS:
.list_item:hover {
background-color:green;
}
.sub_list_item:hover {
background-color:yellow;
}
Wrap item 2 around its <ul> tag
<ul>
<li class="list_item">Item 1</li>
<li class="list_item">Item 2
<ul>
<li class="sub_list_item">Sub Item 1</li>
<li class="sub_list_item">Sub Item 2</li>
</ul>
</li>
<li class="list_item">Item 3</li>
</ul>
You could use the direct child selector > to target a specific li as opposed any given li or ul.
jsFiddle here - menu I made a few weeks ago
Usage example:
#menu > ul > li:hover {
background: #2580a2;
}
Change the code and css
<ul class="item">
<li class="list_item">Item 1</li>
<li class="list_item">Item 2</li>
<ul>
<li class="sub_list_item">Sub Item 1</li>
<li class="sub_list_item">Sub Item 2</li>
</ul>
<li class="list_item">Item 3</li>
</ul>
CSS is
.item
{
color: #000000;
list-style-type: disc;
}
.item li:hover
{
color: #FFFFFF;
background-color: #336600;
}
.item ul li:hover
{
color: #FFFFFF;
background-color: #FF0000;
}
Enjoy ... and choose your color whatever you like
for more detail visit ..
http://www.mr-sudhir.com/blog/what-is-css.aspx
I want to create a top header with the logo in the center and navigation options to it's left and right.
Below is what I have so far but not sure how to take it form there. What can I do to accomplish this?
<div class="header">
<div class="nav">
<ul>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
<li>Option 4</li>
<img class="logo_home" src="logo.png" height="100">
<li>Option 5</li>
<li>Option 6</li>
<li>Option 7</li>
<li>Option 8</li>
</ul>
</div>
</div>
CSS:
ul {
list-style:none;
}
li {
display:inline;
}
.header {
background-color: #999;
width: 100%;
height: 80px;
top: 0;
left: 0;
position:absolute;
}
.logo_home {
display:block;
margin-left:auto;
margin-right:auto;
}
Here is a fiddle about what i think you are trying to achieve.
Change the li inline to float , and now the ul needs to be modified to your needs, so it can be centered.
here is another fiddle which i think is exactly what you are trying to achieve.
you just need to remove the display:block to the image and add text-align:center to the ul.
like this the elements are in the center.
So here is the html
<div class="header">
<div class="nav">
<ul>
<li href="#">Option 1</li>
<li href="#">Option 2</li>
<li href="#">Option 3</li>
<li href="#">Option 4</li>
<li><img class="logo_home" src="logo.png" height="100" /></li>
<li href="#">Option 5</li>
<li href="#">Option 6</li>
<li href="#">Option 7</li>
<li href="#">Option 8</li>
</ul>
</div>
</div>
and here is your css
ul {
list-style:none;
text-align:center;/* this will center your items*/
}
li {
margin: 0 5px;
display:inline;
}
.header {
background-color: #999;
width: 100%;
height: 80px;
}
.logo_home {
margin-left:auto;
margin-right:auto;
/*removed display:block*/
}
I changed display: inline from li to float: left and wrapped the img in the li tag. Looks like it is what you are looking for: FIDDLE
That is to go further. I would divide left and right to two classes, also place links.
.logo_home img{
margin:0 auto;
}
.navleft {
float: left;
width: 500px;
height: 90px;
margin: 0 auto;
padding: 0;
}
.navleft li {
float: left;
padding: 5px 5px 5px 5px;
}
.navright {
float: right;
width: 500px;
height: 90px;
margin: 0 auto;
padding: 0;
}
.navright li {
float: left;
padding: 5px 5px 5px 5px;
}
</style>
</head>
<body>
<div class="header">
<ul>
<div class="navleft">
<li><a href="#">Option 1</li>
<li><a href="#">Option 2</li>
<li><a href="#">Option 3</li>
<li><a href="#">Option 4</li>
</div>
<img class="logo_home" src="logo.png" height="100">
<div class="navright">
<li><a href="#">Option 5</li>
<li><a href="#">Option 6</li>
<li><a href="#">Option 7</li>
<li><a href="#">Option 8</li>
</ul>
</div>
</div>
Something like this would do it-
.left-li {
float:left;
}
img {
float:left;
}
.right-li {
float:left;
}
Here's the HTML
<div class="header">
<div class="nav">
<ul class="left-li">
<li href="#">Option 1</li>
<li href="#">Option 2</li>
<li href="#">Option 3</li>
<li href="#">Option 4</li>
</ul>
<img class="logo_home" src="logo.png" height="100">
<ul class="right-li">
<li href="#">Option 5</li>
<li href="#">Option 6</li>
<li href="#">Option 7</li>
<li href="#">Option 8</li>
</ul>
</div>
I think this is what you want:
http://jsfiddle.net/VWcVw/
Setting everything to display: inline and putting the image in an <li> tag.
EDIT: Here's a better version, with the links on either side of the logo stacking horizontally. http://jsfiddle.net/VWcVw/1/