html-lists

Can you have <li>s without them being under a <ul> or <ol>?

半世苍凉 提交于 2019-12-30 08:25:58
问题 I have a navigation that I am using a list for. I have it in a <ul> , but that is messing up my UI because it has weird automatic margins. I tried without the <ul> and they seem to work. Would this work across all browsers? Is this legal? Anybody else done this before? 回答1: It's probably working in browsers because browsers are too forgiving, but that's not valid says the validator: Document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag Well, you

Add a different ID to each li element by jQuery

对着背影说爱祢 提交于 2019-12-30 06:07:08
问题 I'm new here and I'd like to ask a question about jQuery. I have the unordered list like: <ul id="pages"> <li class="something"><a href="#"></a></li> <li class="something"><a href="#"></a></li> <li class="something"><a href="#"></a></li> </ul> And I'd like to add a different ID to every li displayed in this <ul> (eg. <li class="something" id="li1">... ). Is there a way how to achieve this via jQuery? Thanks a lot, Jakub 回答1: As of jQuery 1.4, you can do this: $('#pages li').attr('id',

Add a different ID to each li element by jQuery

瘦欲@ 提交于 2019-12-30 06:04:30
问题 I'm new here and I'd like to ask a question about jQuery. I have the unordered list like: <ul id="pages"> <li class="something"><a href="#"></a></li> <li class="something"><a href="#"></a></li> <li class="something"><a href="#"></a></li> </ul> And I'd like to add a different ID to every li displayed in this <ul> (eg. <li class="something" id="li1">... ). Is there a way how to achieve this via jQuery? Thanks a lot, Jakub 回答1: As of jQuery 1.4, you can do this: $('#pages li').attr('id',

How can I create a horizontal menu with each item being equal width and spacing inbetween?

社会主义新天地 提交于 2019-12-30 03:35:09
问题 Here's what I've got so far: fiddle 2 problems with it though: I've hard-coded the width of each li to 33% , which I'd prefer not to do so that I can easily add more items. I want to put some spacing between each item (a gap in the background color), but as soon as I add a margin, one item will be bumped down a line. How do I get around that? #main-nav { list-style: none; margin: 0; padding: 0; width: 100%; overflow: auto; } #main-nav li { float: left; width: 33%; height: 25px; text-align:

How to indent the text in a custom unordered list

本秂侑毒 提交于 2019-12-29 09:13:45
问题 Fiddle: http://jsfiddle.net/pgf0ckfj/1/ CSS: ul { list-style: none; padding: 0 0 0 45px; } ul li:before { content: "♦ "; color: #E55302; } As you can see the text is not indented like the normal UL . How can I modify the CSS to ensure the text is indented for anything overflowing to the next line. 回答1: Set the li to position: relative; and then your pseudo element to position: absolute; along with a negative left value. Adding relative positioning will make sure that your absolute positioned

CSS center ul list

你离开我真会死。 提交于 2019-12-29 08:15:21
问题 I have this list here: jsfiddle <div class="footer-location"> <ul> <li>123 Fake St.</li> <li>Toronto, Ontario, Y1Y 1Y1</li> <li>416-555-5555</li> <li><a href="mailto:info@email.com">info@email.com</a></li> </ul> </div> And I am trying to center the whole list, I tried setting a width and set margin to 0 auto, but it did't do anything, here is my css code: .footer-location { float: left; width: 100%; padding-right: 20px; padding-left: 25px; margin: 0 auto; text-align: center; } .footer

How to get list item (<li>) marker/label declared in list-style-type?

天涯浪子 提交于 2019-12-29 05:55:47
问题 Lets say I have a list like this: <ul style="list-style-type: upper-latin;"> <li>Lorem</li> <li>Ipsum</li> </ul> ( list-style-type might be anything - upper-roman, katakana, lower-greek) list-style-type: upper-latin; will put a alphabet letter (starting from A) in front of every list item. Is there a way to get this letter for any given list item? I can probably iterate over list using jQuery .index() or similar. Or, maybe there is way to extract markers from style? The answer here works only

CSS Change List Item Background Color with Class

蹲街弑〆低调 提交于 2019-12-29 05:21:08
问题 I am trying to change the background color of one list item while there is another background color for other list items. This is what I have: <style type="text/css"> ul.nav li { display:inline; padding:1em; margin:1em; background-color:blue; } .selected { background-color:red; } <ul class="nav"> <li>Category 1</li> <li>Category 2</li> <li class="selected">Category 3</li> <li>Category 4</li> </ul> What this produces is all list items with a blue background (from the "nav" class), as if there

How to write W3C compliant multi-level bullet points in HTML?

无人久伴 提交于 2019-12-29 04:27:06
问题 Is it possible to write W3C compliant multi-level bullet points (unordered list) in HTML? Nested ul can be used, but is not W3C compliant. <ul> <li>myItem 1</li> <li>myItem 2</li> <ul> <li>myItem 2a</li> </ul> <li>myItem 3</li> <li>myItem 4</li> </ul> myItem 1 myItem 2 myItem 2a myItem 3 myItem 4 In Visual Studio, the above code gives the warning: Validation (XHTML 1.0 Transitional): Element 'ul' cannot be nested within element 'ul' 回答1: The only valid child of either a ul or ol is an li

How to get ordered list into pdf using itext?

半世苍凉 提交于 2019-12-25 17:03:14
问题 I have to get an ordered list into pdf.The data stored is in html format.When exporting to pdf using itextsharp,the ol-li tags should be replaced by an ordered list. 回答1: You'll want to use iTextSharp's iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList() method. Below is a full working sample WinForms app targeting iTextSharp 5.1.1.0 that does what you're looking for. See the inline comments for what's going on. using System; using System.Collections.Generic; using System.Linq; using