trying to break the li for every 3 elements in a row - html

I have this code, it is working but not entirely
ul {
columns: 3;
-webkit-columns: 3;
-moz-columns: 3;
}
<ul>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
<li>Some text</li>
</ul>
The problem is with the above, if everything is divided in 3 rows, if I have an extra element, it is not creating a new line and adding only 1 element to it, neither it does for 2, it always seems to have columns to be shown in 3 instead of li breaking at extra ones.
I am open to div, or span, or li if my code should work as to what I am trying to do with li, I will apply css to hide that piece of code which shows bullets.

The problem is that the columns are each being populated completely before moving on to the next column. This will leave you with an unbalanced final column.
By making the ul element a flex container, the li elements are displayed side by side. The flex-wrap property set to wrap allows the li elements to wrap to a new line when the container width is exceeded.
The flex-basis property set to calc(100% / 3) specifies that each li should take up one-third of the container's width.
Please see if this CSS works for you:
ul {
display: flex;
flex-wrap: wrap;
}
li {
flex-basis: calc(100% / 3);
}

Related

Nested ordered list inside unordered

I'm using lists for "Terms and conditions" page and in order to make the structure neater I'm using ordered lists. Problem is that I want to make the outer list unordered, and when I do that it's losing the count for the nested ordered lists. I know I can make it in many ways including manually, but I want to know if it's possible to handle this situation somehow.
<ol>
<li>
<h2>Title of section 1</h2>
<ol>
<li>Text 1.1
<li>
<li>Text 1.2
<ol>
<li>Text 1.2.1</li>
<li>Text 1.2.2</li>
</ol>
</li>
</ol>
</li>
<li>
<h2>Title of section 2</h2>
<ol>
<li>Text 2.1
<li>
<li>Text 2.2
<ol>
<li>Text 2.2.1</li>
<li>Text 2.2.2</li>
</ol>
</li>
</ol>
</li>
</ol>
Using CSS I'm able to show everything as it should be
https://jsfiddle.net/tutancamon/bfhkqtdg/41/
What I want is to remove the number in front of the titles because it already contains them...
Unorderded list element <ul> sounds like what you need to use.
ul {
list-style: none;
}
<ul>
<li>
<h2>Title of section 1</h2>
<ol>
<li>Text 1.1
<li>
<li>Text 1.2
<ol>
<li>Text 1.2.1</li>
<li>Text 1.2.2</li>
</ol>
</li>
</ol>
</li>
<li>
<h2>Title of section 2</h2>
<ol>
<li>Text 2.1
<li>
<li>Text 2.2
<ol>
<li>Text 2.2.1</li>
<li>Text 2.2.2</li>
</ol>
</li>
</ol>
</li>
</ul>
Use css property list-style-type like so:
ol.outer {
list-style-type: none;
}
This will however mess with the numbering. Which you can fix like so:
ol {
list-style-type: none;
counter-reset: item;
}
ol>li::before {
counter-increment: item;
content: counters(item, ".") " ";
}
ol.outer>li::before {
content: "";
}
<ol class="outer">
<li>
<h3>Section1</h3>
<ol>
<li> text1.</li>
<li> text2 </li>
<li> text3</li>
</ol>
</li>
<li>
<h3>section 2</h3>
<ol>
<li> text</li>
<li> text</li>
<li>
<strong>Some texts</strong>
<ol>
<li>text</li>
<li>text</li>
<li>text</li>
</ol>
</li>
</ol>
</li>
</ol>

Nesting a ul inside an ol

Im trying to make an ordered list with two items, and three items under each list, which have bullet points. my code is not passing validation because it saysElement ul not allowed as child of element ol in this context. But everywhere I look it says this is ok. here is my code
<ol>
<li>First numbered Item</li>
<ul>
<li>one thing</li>
<li>two things</li>
<li>three things</li>
</ul>
<li>Second numbered Item</li>
<ul>
<li>one thing</li>
<li>two things</li>
<li>Three things</li>
</ul>
</ol>
not sure what im doing wrong. thanks for the help, first post here :)
The children of lists should be list items. You have both list items and unordered lists as children of your ordered list. You need something like:
<ol>
<li>
<p>First numbered Item</p>
<ul>
<li>one thing</li>
<li>two things</li>
<li>three things</li>
</ul>
</li>
<li>
<p>Second numbered Item</p>
<ul>
<li>one thing</li>
<li>two things</li>
<li>Three things</li>
</ul>
</li>
</ol>

display/float, styling a list

I'm redoing a html table into a list.
It now looks like this:
<ul>
<li>Some fruits
<ul>
<li>2013
<ul>
<li>Apple</li>
<li>Kiwi</li>
</ul>
</li>
</ul>
</li>
<li>Some other fruits
<ul>
<li>2012
<ul>
<li>Banana</li>
</ul>
</li>
<li>2011
<ul>
<li>Lemon</li>
<li>Orange</li>
<li>Plum</li>
</ul>
</li>
<li>2009
<ul>
<li>Peach</li>
<li>Pear</li>
</ul>
</li>
</ul>
</li>
</ul>
I'm trying to figure out how to make the first entry in the sublist to align horizontally with the year. Like this:
2011 Lemon
Orange
Plum
The nested elements are doing my head in and I'm stuck. I have a feeling this will involve the display type of the elements and some floating. Any ideas? Fiddle here: http://jsfiddle.net/HUH62/4/
Thanks.
If I understood correctly, here's the same fiddle modified according to what you are trying to accomplish: fiddle.
I added some classes in order to make the CSS more readable and wrapped the "subtitle" of each section in a div so that floatiing could be applied to them.
I also removed the colors, since I interpreted they were added only for visualizing the elements.
CSS
h4 {
margin: 0px;
padding: 0px;
float:left;
}
ul {
list-style: none outside none;
padding: 0;
}
ul li ul li ul {
float:left;
margin-left: 10px;
}
ul li {
clear:both;
}
HTML
<ul>
<li>Some fruits
<ul>
<li>
<h4>2013</h4>
<ul>
<li>Apple</li>
<li>Kiwi</li>
</ul>
</li>
</ul>
</li>
<li>Some other fruits
<ul>
<li>
<h4>2012</h4>
<ul>
<li>Banana</li>
</ul>
</li>
<li>
<h4>2011</h4>
<ul>
<li>Lemon</li>
<li>Orange</li>
<li>Plum</li>
</ul>
</li>
<li>
<h4>2009</h4>
<ul>
<li>Peach</li>
<li>Pear</li>
</ul>
</li>
</ul>
</li>
</ul>

Horizontal column of buttons, left alligned

I am trying to create a column of buttons but I want them left aligned.
I have tried many things but am new at css/html5.
Use an unordered list:
<ul>
<li><img src="/images/yourimage.png />Some Text</li>
<li><img src="/images/yourimage.png />Some Text</li>
<li><img src="/images/yourimage.png />Some Text</li>
</ul>

Display lists next to each other without float

I am trying to display unordered lists next to each other but can't get it to work even when I use css rules to match the way they display.
Heres my code:
<ul class="outterList">
<li>
<span class="bigText">Main</span>
</li>
<li>
<span class="medText">Included</span>
<ul class="innerList">
<li>TestMessage - text</li>
<li>bla - text</li>
<li>asffadgsd - text</li>
<li>iuygouhlubrsf - text</li>
<li>New Test - text</li>
<li>TestFileName - photo</li>
<li>TestFileName2 - photo</li>
<li>jvv - photo</li>
<li>ujjjjjjjjjjj - photo</li>
<li>MR. Bean - text</li>
</ul>
</li>
</ul>
And my CSS:
.outterList{
display: inline ;
}
.innerList{
display: block;
}
What Im trying to show is somthing like:
List1(empty list) List2
*item1
*item2
Anyone knows how to fix this?
.outterList{
display: block;
}
.outterList > li {
display: inline-block;
vertical-align: top;
}
Demo: http://jsfiddle.net/Q8qNj/4/