Got a strange issue:
In my .cshtml I have a second thing:
<ul>
<li>Test</li>
<li>Test2
<ul>
<li>Test3</li>
</ul>
</li>
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
</li>
</ul>
Which supposed to work like this:
Test
Test2
Test3
Test4
Test5
Test6
BUT instead of it, it works this way:
Test
Test2
Test3
Test4
Test5
Test6
The only thing I have in css for this is list-style: none;
Also main <ul> is placed inside of <div> which have text-align: left; (without it, all items are centered).
I am a newbie speaking of css so, I can't get, what I am missing.
EDIT:
Forgot one thing. This works fine in jsfiddle.
Just reset all your styles and give </li>. You are using <li> only for opening and closing it:
<ul>
<li>Test</li>
<li>Test2
<ul>
<li>Test3</li>
</ul>
</li>
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
</li>
</ul>
Your Mistake
<ul>
<li>Test<li> <!-- Should be </li> not <li> -->
<li>Test2
<ul>
<li>Test3</li>
</ul>
<li><!-- Should be </li> not <li> -->
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
<li><!-- Should be </li> not <li> -->
</ul>
Preview:
Just check this out...
OR
Provide the CSS you have used..
div {
text-align: left;
}
ul {
list-style: none;
}
<div>
<ul>
<li>Test</li>
<li>Test2
<ul>
<li>Test3</li>
</ul>
</li>
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
</li>
</ul>
</div>
I guess this might be your issue.
padding:0px;
margin:0px;
ul li ul
{
padding:0px;
}
<ul>
<li>Test</li>
<li>Test2
<ul>
<li>Test3</li>
</ul>
</li>
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
</li>
</ul>
ANSWER
Note : So remove padding property from your ul CSS.
ul li ul
{
/* padding:0px; REMOVE IT If It's 0PX' */
}
<ul>
<li>Test</li>
<li>Test2
<ul>
<li>Test3</li>
</ul>
</li>
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
</li>
</ul>
The solution that I came up with is that you should wrap your un-ordered list with div tag that has a class name. Ex. <div class="test"></div>
HTML:
<div class="test">
<ul>
<li>Test</li>
<li>Test2
<ul>
<li>Test3</li>
</ul>
</li>
<li>Test4
<ul>
<li>Test5</li>
</ul>
<ul>
<li>Test6</li>
</ul>
</li>
</ul>
</div>
CSS
.test ul li {
list-style: none;
text-align: left;
}
Related
I've the following code with nested list items as shown below:
<ul style={{padding-top: '15px'}}>
<li style={{margin-left: '20px'}}>First Services</li>
<ul style={{margin-left: '30px'}}>
<li>get1</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get2</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get3</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get4</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get5</li>
</ul>
<li style={{margin-left: '20px'}}>Second Services</li>
<ul style={{margin-left: '30px'}}>
<li>get6</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get7</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get8</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get9</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get10</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get11</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get12</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get13 </li>
</ul>
<li style={{margin-left: '20px'}}>Workflows</li>
<ul style={{margin-left: '30px'}}>
<li>Workflow for someone </li>
</ul>
</ul>
My Goal:
I want some space between the following:
1) First Services and get1
2) get5 and Second Services
3) Second Services and get6
4) get13 and Workflows
5)Workflows and Workflow for someone
How should I go about it? Is adding an empty paragraph tag <p></p> a good idea between each of the above 5 things?
if you mean horizontal space (white space), use:   ;
if you mean vertical space, try: (CSS property) line-height, padding
or margin.
you might want to remove this from being inline and use your linked stylesheet instead as it might cause issues with your styling.
You should use classes for this. Right now, the simplest way is to wrap a div around your whole list, apply a class to it (in my example I used parent_class) and use this selector: div.parent_class > ul >li It only selects the li elements of the first level ul:
div.parent_class > ul >li {
margin-top: 10px;
margin-bottom: 10px;
}
<div class="parent_class">
<ul style="padding-top:15px;">
<li style="margin-left:20px">First Services</li>
<ul style="margin-left:30px">
<li>get1</li>
</ul>
<ul style="margin-left:30px">
<li>get2</li>
</ul>
<ul style="margin-left:30px">
<li>get3</li>
</ul>
<ul style="margin-left:30px">
<li>get4</li>
</ul>
<ul style="margin-left:30px">
<li>get5</li>
</ul>
<li style="margin-left:20px">Second Services</li>
<ul style="margin-left:30px">
<li>get6</li>
</ul>
<ul style="margin-left:30px">
<li>get7</li>
</ul>
<ul style="margin-left:30px">
<li>get8</li>
</ul>
<ul style="margin-left:30px">
<li>get9</li>
</ul>
<ul style="margin-left:30px">
<li>get10</li>
</ul>
<ul style="margin-left:30px">
<li>get11</li>
</ul>
<ul style="margin-left:30px">
<li>get12</li>
</ul>
<ul style="margin-left:30px">
<li>get13 </li>
</ul>
<li style="margin-left:20px">Workflows</li>
<ul style="margin-left:30px">
<li>Workflow for someone </li>
</ul>
</ul>
</div>
.example-list {
margin:0px;
}
.example-list > li {
margin: 30px 0px;
}
<ul class="example-list">
<li>First Services</li>
<ul>
<li>get1</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get2</li>
</ul>
<ul style={{margin-left: '30px'}}>
<li>get3</li>
</ul>
<ul>
<li>get4</li>
</ul>
<ul>
<li>get5</li>
</ul>
<li style={{margin-left: '20px'}}>Second Services</li>
<ul>
<li>get6</li>
</ul>
<ul>
<li>get7</li>
</ul>
<ul>
<li>get8</li>
</ul>
<ul>
<li>get9</li>
</ul>
<ul>
<li>get10</li>
</ul>
<ul>
<li>get11</li>
</ul>
<ul>
<li>get12</li>
</ul>
<ul>
<li>get13 </li>
</ul>
<li style={{margin-left: '20px'}}>Workflows</li>
<ul>
<li>Workflow for someone </li>
</ul>
</ul>
I would do the following (or something similar - keep in mind it's not good practice to have <ul> as a child of another <ul> - you can validate here: http://validator.w3.org/). Remove the inline styles, you'll deal with A LOT of headaches later if you write you CSS as you have. Set classnames for the bits you want extra space for (you can edit the {{20px}} below for how much space you want (or if you want left/right margins, you can edit the whole rule).
<style>
.title {
margin-left: 20px;
}
.top-list {
padding-top: 15px;
}
.top-list .spacer-top {
margin-top: {{20px}};
}
.top-list > li > ul {
margin-left: 30px;
}
</style>
<ul class="top-list">
<li class="title">First Services</li>
<li class="spacer-top">
<ul>
<li>get1</li>
</ul>
</li>
<li>
<ul>
<li>get2</li>
</ul>
</li>
<li>
<ul>
<li>get3</li>
</ul>
</li>
<li>
<ul>
<li>get4</li>
</ul>
</li>
<li>
<ul>
<li>get5</li>
</ul>
</li>
<li class="title" class="spacer-top">Second Services</li>
<li class="spacer-top">
<ul>
<li>get6</li>
</ul>
</li>
<li>
<ul>
<li>get7</li>
</ul>
</li>
<li>
<ul>
<li>get8</li>
</ul>
</li>
<li>
<ul>
<li>get9</li>
</ul>
</li>
<li>
<ul>
<li>get10</li>
</ul>
</li>
<li>
<ul>
<li>get11</li>
</ul>
</li>
<li>
<ul>
<li>get12</li>
</ul>
</li>
<li>
<ul>
<li>get13 </li>
</ul>
</li>
<li class="title spacer-top">Workflows</li>
<li class="spacer-top">
<ul>
<li>Workflow for someone </li>
</ul>
</li>
</ul>
I tried to make a Hoverable text, but it gives me a little visual error. I want to make it in this way: http://i.imgur.com/fg1NTab.png
but at my website it gives in this way.
http://vestigedayz.com/wqeq
(press on the A from menu on my website)
This is my CODE.
<div class="liste">
<div class="dropdown">
<ul> <li>A</li> </ul>
<div class="dropdown-content">
<li>AA</li>
<li>AB</li>
<li>AC</li>
<li>AD</li>
</div>
</div>
<ul> <li>B</li> </ul>
<ul> <li>c</li> </ul>
<ul> <li>d</li> </ul>
<ul> <li>e</li> </ul>
<ul> <li>f</li> </ul>
<ul> <li>g</li> </ul>
<ul> <li>h</li> </ul>
<ul> <li>i</li> </ul>
<ul> <li>j</li> </ul>
<ul> <li>k</li> </ul>
<ul> <li>l</li> </ul>
<ul> <li>m</li> </ul>
<ul> <li>n</li> </ul>
<ul> <li>o</li> </ul>
<ul> <li>p</li> </ul>
<ul> <li>q</li> </ul>
<ul> <li>r</li> </ul>
<ul> <li>s</li> </ul>
<ul> <li>t</li> </ul>
<ul> <li>u</li> </ul>
<ul> <li>v</li> </ul>
<ul> <li>w</li> </ul>
<ul> <li>y</li> </ul>
<ul> <li>z</li> </ul>
</div>
</div>
</div>
AND THE STYLE CSS
.header .liste {background:#ffd564;border-bottom:5px solid #ffecb8;font-size:13px;height:50px;overflow:hidden;padding-left:25px;margin-top:30px;}
.header .liste > ul li {float:left;padding-right:30px;margin:17px 0;}
.header .liste > ul li a {text-decoration:none;color:#1b1b1b;text-transform:uppercase;}
.dropdown {
position: fixed;
display: table;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #ffecb8;
min-width: 950px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
}
.dropdown:hover .dropdown-content {
display: inline-table;
}
Ok, to get A in the right spot you have to put that ul element on the same level as other ul elements (B, C, D etc.)
So change your list div like this
<div class="liste">
<ul><li>A</li></ul>
<div class="dropdown">
<div class="dropdown-content">
<li>AA</li>
<li>AB</li>
<li>AC</li>
<li>AD</li>
</div>
</div>
<ul> <li>B</li> </ul>
<ul> <li>c</li> </ul>
<ul> <li>d</li> </ul>
<ul> <li>e</li> </ul>
<ul> <li>f</li> </ul>
<ul> <li>g</li> </ul>
<ul> <li>h</li> </ul>
<ul> <li>i</li> </ul>
<ul> <li>j</li> </ul>
<ul> <li>k</li> </ul>
<ul> <li>l</li> </ul>
<ul> <li>m</li> </ul>
<ul> <li>n</li> </ul>
<ul> <li>o</li> </ul>
<ul> <li>p</li> </ul>
<ul> <li>q</li> </ul>
<ul> <li>r</li> </ul>
<ul> <li>s</li> </ul>
<ul> <li>t</li> </ul>
<ul> <li>u</li> </ul>
<ul> <li>v</li> </ul>
<ul> <li>w</li> </ul>
<ul> <li>y</li> </ul>
<ul> <li>z</li> </ul>
</div>
Then find these properties and remove padding left:
.header .liste {
background: #ffd564;
border-bottom: 5px solid #ffecb8;
font-size: 13px;
height: 50px;
overflow: hidden;
/* padding-left: 25px; */
margin-top: 30px;
}
Then move your opened dropdown down (top: 50px)and change min width to 948px
.dropdown-content {
/* display: none; */
position: absolute;
background-color: #ffecb8;
min-width: 948px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
top: 50px;
}
Then give your liste li padding left:
.liste li {
padding-left: 25px;
}
And here is the screenshot of the result: http://screencast.com/t/RD3Akbot
Also, because structure changed you will have to deal with hover.
Here is the code for the hover:
.liste ul:hover + .dropdown {
display: block;
}
This says, when you hover over this ul element show next .dropdown div. So all you have to do is add .dropdown sections underneath appropriate ul section. I will add the code snippet below.
<ul> <li>A</li> </ul>
<div class="dropdown">
<div class="dropdown-content">
<li>AA</li>
<li>AB</li>
<li>AC</li>
<li>AD</li>
</div>
</div>
<ul> <li>B</li> </ul>
<div class="dropdown">
<div class="dropdown-content">
<li>AA777</li>
<li>AB777</li>
<li>AC777</li>
<li>AD777</li>
</div>
</div>
Oh, I forgot you have to declare your .dropdown display:none too. So when you hover it will display block.
I want to select with css the last of child <li> that text appear gg
I want only select Last gg <li> Please Help
ul {
margin: 0;
padding: 0;
}
.container ul li + li:nth-last-child(1) li:last-child {
border: 1px solid red
}
<div class="container">
<ul class="ng-scope">
<li>
<ul>
<li>a</li>
</ul>
</li>
<li>
aa
<ul>
<li>
bb
<ul>
<li>
cc
<ul>
<li>
dd
<ul>
<li>
ee
<ul>
<li>
ff
<ul>
<li>
gg
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
Try this
ul { margin:0; padding:0;}
.gg{
color:red;
}
<div class="container">
<ul class="ng-scope">
<li>
<ul>
<li>a</li>
</ul>
</li>
<li>
aa
<ul>
<li>
bb
<ul>
<li>
cc
<ul>
<li>
dd
<ul>
<li>
ee
<ul>
<li>
ff
<ul>
<li class="gg">
gg
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
This is my scenario
(JsFiddle Link at the end of page)
I want to center the buttons "Home", "Categories", "Work", ecc ecc inside the same bar.
In other words, now is on left side; I want to center it.
<nav id="menu-wrap">
<ul id="menu">
<li>Home</li>
<li>
Categories
<ul>
<li>
CSS
<ul>
<li>Item 11</li>
<li>Item 12</li>
<li>Item 13</li>
<li>Item 14</li>
</ul>
</li>
<li>
Graphic design
<ul>
<li>Item 21</li>
<li>Item 22</li>
<li>Item 23</li>
<li>Item 24</li>
</ul>
</li>
<li>
Development tools
<ul>
<li>Item 31</li>
<li>Item 32</li>
<li>Item 33</li>
<li>Item 34</li>
</ul>
</li>
<li>
Web design
<ul>
<li>Item 41</li>
<li>Item 42</li>
<li>Item 43</li>
<li>Item 44</li>
</ul>
</li>
</ul>
</li>
<li>
Work
<ul>
<li>
Work 1
<ul>
<li>
Work 11
<ul>
<li>Work 111</li>
<li>Work 112</li>
<li>Work 113</li>
</ul>
</li>
<li>
Work 12
<ul>
<li>Work 121</li>
<li>Work 122</li>
<li>Work 123</li>
</ul>
</li>
<li>
Work 13
<ul>
<li>Work 131</li>
<li>Work 132</li>
<li>Work 133</li>
</ul>
</li>
</ul>
</li>
<li>
Work 2
<ul>
<li>
Work 21
<ul>
<li>Work 211</li>
<li>Work 212</li>
<li>Work 213</li>
</ul>
</li>
<li>
Work 22
<ul>
<li>Work 221</li>
<li>Work 222</li>
<li>Work 223</li>
</ul>
</li>
<li>
Work 23
<ul>
<li>Work 231</li>
<li>Work 232</li>
<li>Work 233</li>
</ul>
</li>
</ul>
</li>
<li>
Work 3
<ul>
<li>
Work 31
<ul>
<li>Work 311</li>
<li>Work 312</li>
<li>Work 313</li>
</ul>
</li>
<li>
Work 32
<ul>
<li>Work 321</li>
<li>Work 322</li>
<li>Work 323</li>
</ul>
</li>
<li>
Work 33
<ul>
<li>Work 331</li>
<li>Work 332</li>
<li>Work 333</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
http://jsfiddle.net/uHuHE/
Just assign text-align: center; to #menu ul a
Demo
Side Note: If you want to be over specific with the nested level text alignment, you can always use > selector so say for example you want to align the text in 1st drop down level, than you can simply use
ul#menu > li {
/* Targets main menu items */
}
ul#menu > li > ul > li > a {
/* Targets 1st level dropdown */
}
And so on...
As you commented, you wanted to center the main menu items, than use #menu-wrap in the place of #menu {} declaration, assign some fixed width to your #menu and than use margin: auto;
Demo 2
I'm a novice and ran my code through an html validator.
Regarding my navigation I receive a message that reads: :Element ul not allowed as child of element ul in this context"
Here is the html structure:
<nav>
<div class="nav_container">
<ul class="navigation">
<ul class="logo">
<li><img src="images/rh_logo_v5.png" alt="roundhaus logo"/></li>
</ul>
<ul class="subnav">
<li>home</li>
</ul>
<ul class="subnav">
<li>reclaimed wood</li>
<li>design</li>
</ul>
<ul class="subnav">
<li>flooring</li>
<li>paneling</li>
<li>beams</li>
</ul>
<ul class="subnav">
<li>shelving
</li><li>mantels</li>
</ul>
<ul class="subnav">
<li>news</li>
</ul>
<ul class="subnav">
<li>wood types</li>
<li>phrases</li>
</ul>
</ul>
</div>
</nav>
Whats wrong with it? It looks fine across browsers. Should I be concerned or take action?
A ul can not be a direct child of another ul, it needs to be contained within an li
<ul class="navigation">
<li>
<ul class="logo">
<li><img src="images/rh_logo_v5.png" alt="roundhaus logo"/></li>
</ul>
</li>
<li>
<ul class="subnav">
<li>home</li>
</ul>
</li>
<li>
<ul class="subnav">
<li>reclaimed wood</li>
<li>design</li>
</ul>
</li>
<li>
<ul class="subnav">
<li>flooring</li>
<li>paneling</li>
<li>beams</li>
</ul>
</li>
<li>
<ul class="subnav">
<li>shelving</li>
<li>mantels</li>
</ul>
</li>
<li>
<ul class="subnav">
<li>news</li>
</ul>
</li>
<li>
<ul class="subnav">
<li>wood types</li>
<li>phrases</li>
</ul>
</li>
</ul>
you could also give the menu some headings by adding it in the li before the child ul,
you must wrap each of the inner ul with an li
<ul class="navigation">
<li>
<ul>
<li>...</li>
</ul>
</li>
<li>
<ul>
<li>...</li>
</ul>
</li>
<li>
<ul>
<li>...</li>
</ul>
</li>
</ul>
Your structure is likely wrong. Logo is not a list or list-item. As well as list item that contains just another list is generally pointless.
Use heading element for logo (I usually use H1 for home page and H3 with link inside it for other pages):
<!-- for home page -->
<h1 id="logo">Company</h1>
<!-- for other pages -->
<h3 id="logo">Company</h3>
And make sure that your navigation has correct hierarchy like this:
<ul>
<li>Products
<ul>
<li>Desktops</li>
<li>Laptops</li>
<li>Tablets</li>
</ul>
</li>
<li>About
<ul>
<li>History</li>
<li>Contacts</li>
</ul>
</li>
</ul>
In the example, each LI has its own link and subsections of section that the link represents, and thus the link text is heading for subsections' list.
You need to wrap
<ul class="navigation">
<ul class="logo">
as
<ul class="navigation">
<li>
<ul class="logo">
...
</ul>
</li>
and so on...