html-lists

Turning an unordered list into a table of contents

拜拜、爱过 提交于 2019-12-05 06:51:18
Reference this fiddle: http://jsfiddle.net/exGnZ/ Hi, I'm trying to reproduce a table of contents with an unordered list and leader dots. Unfortunately, when there's a long line of content, the formatting breaks down. Does anyone know how to get Chapter 2 in the image below to appear on the same line as the dots? Here's the code I've got at the moment: http://jsfiddle.net/exGnZ/ I'm also pasting it here: <div> <ul id="toc"> <li><span>Introduction</span> <a href="#">Chapter 1</a></li> <li><span> Storm clouds looming Storm clouds looming Storm clouds looming Storm clouds looming Storm clouds

<li> elements with adapted width

六月ゝ 毕业季﹏ 提交于 2019-12-05 06:18:22
I'm wondering if it is possible to do this in CSS, without javascript: A list of N <li> items, with display inline, equal width, and the width of the all equal to the width of the container I can have 3 <li> items, in this case the <li> width will be 33%, or I can have 4 <li> items, then the li width will be 25%. It is possible with CSS3 flex boxes , as demonstrated in this fiddle (for webkit browsers only). There are other browser custom properties that would make this work for recent versions of Firefox and IE. If you need something that works for Opera or older versions of IE then there is

Gap between <li>s

做~自己de王妃 提交于 2019-12-05 05:24:08
To avoid long lists I've got my li set to float: left so that they alternate rows. However, on occasion this causes an unintentional gap between elements when the content in a li takes up two lines. My HTML is: <ul class="gmc-ingredient-list"> <li>500g Tagliatelle</li> <li>50g wortel</li> <li>50g ui</li> <li>50g bleekselderij</li> <li>100g pancetta</li> <li>200g half-om-half-gehakt</li> <li>200g rundergehakt</li> <li>200 ml Primitivo (rode wijn)</li> <li>200ml runderbouillon</li> <li>5 eetlepels tomatenpuree</li> <li>Olijfolie</li> <li>Zeezout</li> <li>Verse peper</li> </ul> My CSS is: ul.gmc

CSS to select all li in ul

血红的双手。 提交于 2019-12-05 05:16:59
I want to write a CSS selector that selects all li elements within a ul element in a document but I don't know how that would be done. Can you help? Mark ul > li { /* css styles go here */ } or ul li { /* css styles go here */ } the first selects only direct children the second selects all li nested within an ul . This should work: ul li { /*css here */} You can use ul li { /* your code here */ } 来源: https://stackoverflow.com/questions/12464500/css-to-select-all-li-in-ul

Cascading <li>-hover effect using CSS [duplicate]

左心房为你撑大大i 提交于 2019-12-05 04:51:11
This question already has an answer here: How to hover only the current li in nested ul? 4 answers I have got an simple html unordered list. <ul> <li>Item 1</li> <li> Group 1 <ul> <li>Item 2</li> <li>Item 3</li> </ul> </li> </ul> I want to use CSS to make a simple effect when the mouse is over an Item or a Group. li:hover { background-color:#ff0000; } It works quite fine for "Group 1" or "Item 1" (not contained in a group) - When I'm moving the mouse over the color changes. But if I move over "Item 2" or "Item 3" "Group 1" also remains hightlighted (red background). In this case I only want to

present lists and sublists in html

白昼怎懂夜的黑 提交于 2019-12-05 02:13:06
how to organize html code (with usage ol\li ect.) to present such lists (with sublists) 1. BLA-BLA-BLA 1.1. Bla-bla-bla. 1.2. Bla-bla-bla. 1.3. Bla-bla-bla: lalal - balalala; lalal - balalala; lalal - lalalla. 1.4. Blal-a lalslas 1.4.1. bklalala 1.4.2. sdsdsdsdsd note: It is not the same that I want vaugham ol tag means ordered list (with numbers). ul tag means unordered one. Overlapping ol lists allow this kind of presentation : 1.1.2 <ol> <li>BLA-BLA-BLA <ol> <li> Bla-bla-bla.</li> <li> Bla-bla-bla.</li> <li> Bla-bla-bla. <ul> <li>lalal - balalala;</li> </ul> </li> </ol> </li> </ol> Bruno

Removing li elements from ul

爱⌒轻易说出口 提交于 2019-12-05 00:30:32
问题 Is it possible using JavaScript to dynamically remove just a few li elements from a ul, given the id's of the li elements? UPDATE about the actual issue: I've the following list. <ul id="attributes" data-role="listview"> <li id="attrib01">Attribute1</li> <li id="attrib02">Attribute2</li> <li id="attrib03">Attribute3</li> <li id="attrib04">Attribute4</li> <li id="attrib05">Attribute5</li> </ul> After a ajax request/response, if a particular attribute is "undefined", I want to remove it from

CSS: :last-child on list item

你说的曾经没有我的故事 提交于 2019-12-05 00:29:38
If a ul has li items with multiple classes, is it possible to get the last item of a specific class using :last-child? For example, consider following: <ul class="test"> <li class="one"> <li class="one"> <li class="one"> <li class="two"> <li class="two"> </ul> I want to add some style to the last li having class "one" (ie. third in the list). I tried following and it does not work. ul.test li.one:last-child That's not possible yet . :last-child selects the last child, regardless of the tag name, etc. The possible alternative, :last-of-type selects the last occurrence of a tag . It ignores the

Ordered List Index

自闭症网瘾萝莉.ら 提交于 2019-12-04 23:06:31
问题 Is there any way to get the number (index) of a li tag in an ordered list? I'm trying to get the number that is shown on the side (the list numbering). I know that the traditional way is to use an id which stores the line number but this would mean that if a line is added in between, a lot of ids would have to be edited. Even though I have developed an algorithm for this, it is not so efficient. I'm looking for a solution to use in Javascript. 回答1: You can use previousElementSibling to jump

Odd “shaking” effect when animating width with jQuery (only in Chrome!)

左心房为你撑大大i 提交于 2019-12-04 21:32:52
问题 I'm animating the width of a li element using jQuery in a simple snippet of code. I'm using hover() as the handler and .animate() to animate the width. Here is my code. $('li').each(function() { //store the original width of the element in a variable var oldWidth = $(this).width(); $(this).hover( function() { //when the mouse enters the element, animate width to 900px $(this).animate({width: '900px'}, 600, 'linear') }, function() { //when the mouse leaves, animate back to the original width $