Remove bullets add tick not working - html

I am trying to remove some bullets points, and replace them with ticks. I can make it work, but then my menu bar mess up. So I need to add a class to the <ul>, so it is not affecting anything else.
I tried to add a class, but still not working. Why?
Not working: Not working
Working but mess up my menu bar: Working
HTML:
<ul class="removeBulletAddTick">
<li class="removeBulletAddTick"> Test text 1</li>
<li class="removeBulletAddTick">Test text 2</li>
<li class="removeBulletAddTick">Test text 3</li>
</ul>
CSS:
ul removeBulletAddTick{
list-style: none;
}
ul li:before {
content: '✓';
}
Update
When I do your suggestion my menubar messed around:
Screenshot of menubar

As it turned out, the class selector wasn't declared correctly, it was missing the period (.) and should be .removeBulletAddTick.
The code below demonstrates this, you'll notice the class in question added to the list item rules as well for more specificity - this is to ensure that these rules will only apply to the list items you intend them to; which are those with the classes .removeBulletAddTick.
ul .removeBulletAddTick {
list-style: none;
}
ul li.removeBulletAddTick:before {
content: '✓';
}
Updated JSFiddle
You don't even need to declare that class on every list item. It would be better to declare it on the containing parent element, as follows:
ul.removeBulletAddTick {
list-style: none;
}
ul.removeBulletAddTick li:before {
content: '✓';
}
Code Snippet Demonstration:
ul.removeBulletAddTick {
list-style: none;
}
ul.removeBulletAddTick li:before {
content: '✓';
}
<ul class="removeBulletAddTick">
<li>Test text 1</li>
<li>Test text 2</li>
<li>Test text 3</li>
</ul>

Related

Overriding the UL Bullets Styling For One Specific List

I'm working on a website where the default CSS specifies:
ul li {
list-style: none;
}
This is necessary to keep the navigation bar clean (which is coded as an unordered list, basically) ...
Now, in the body of text on a particular page, I want to add a standard unordered list. So in a separate CSS sheet that exists for customizations, I added:
ul.about-page {
list-style-type: circle;
}
And then on the page where I want the unordered list, I added this to the HTML:
<ul class="about-page">
<li>Some text</li>
</ul>
I also tried some variations of the above, but in all cases it wasn't working. Instead no bullets were showing up (though the text was indented as expected).
Note: the most complicated thing I tried was to add the following to the custom stylesheet:
ul.about-page li::before {
content: "\25E6";
color: black;
display: inline-block;
width: 1em;
margin-left: -0.9em;
font-weight: bold;
font-size: 1.1em;
}
And then on the page where I want the unordered list, I entered this HTML:
<ul class=“about-page”>
<li>Some text</li>
</ul>
I was hoping that this — or some similar version of it — would work. But it also does not.
I'm sure there must be a way to do this, but after spending at least an hour searching online and trying various things, I can't seem to figure it out.
Any advice will be much appreciated!
when you use class it is have More priority but when you use Address Model Selector like ul li it has more than priority of class then you must use this code
ul li {
list-style: none;
}
ul.about-page li {
list-style-type: circle;
}
<ul>
<li>Item 11</li>
<li>Item12</li>
<li>Item13</li>
</ul>
<ul class="about-page">
<li>Item 11</li>
<li>Item12</li>
<li>Item13</li>
</ul>

Is it possible to prevent li:before from forcing a list item paragraph to the next line (JSFiddle inside)?

I'm using FontAwesome icons as custom bullets for my unordered lists, but using li:before seems to change the behavior of paragraph tags in list items.
See this JSFiddle for a paragraph tag in action in two different lists. One with li:before, one without.
HTML:
<ul class="before">
<li>list item 1</li>
<li>
<p>list item 2 (paragraph)</p>
<p>list item 2 (sub paragraph)</p>
</li>
<li>list item 3</li>
</ul>
<br />
<br />
<ul>
<li>list item 1</li>
<li>
<p>list item 2 (paragraph)</p>
<p>list item 2 (sub paragraph)</p>
</li>
<li>list item 3</li>
</ul>
CSS:
.before li:before {
content:"B4";
color: red;
margin-right: 8px;
}
How can I get list item paragraphs to appear on the same line as the li:before?
Being that paragraphs are block elements, they will start a new line... that is, unless you float the item in front it. There are some other styling issues which arise from this, but I'm sure you can figure those out (I compensated for some of the issues in my example):
http://jsfiddle.net/ryanwheale/ko2efv7b/2/
.before li:before {
content:"B4";
color: red;
margin-right: 8px;
float: left;
}
You should probably accept Ryan's answer, but in case you want a much more hackish answer that doesn't require you to know the width of the before content, here's my attempt:
Fiddle with hiding dots
CSS
.before li {
list-style: dot outside none;
}
.before li:before {
content:"B40M8UW0T?";
color: red;
margin-right: 8px;
float: left;
list-style: dot outside none;
display: list-item;
position: relative;
z-index: 2;
background-color: white;
}
Fiddle with a green background illustrating the hack
So, basically we're telling the browser to display that :before pseudo to display as a list-item itself, and then hiding the resultant bullet point for the actual list item by matching the background-color of the underlying element. In the fiddle I left the ul green to illustrate this happening.
It's not a perfect solution, but there won't be a perfect solution for what you're looking to do without a tremendous amount of effort.
Cheers.

Apply a specific style to a list item using CSS

I have a simple list, which I managed to get in a line and have background image for all items. However I want to have some of the list items(List item 3) to have a different background image. Is there a way to do this without using !important? My code is Below.
The CSS
.my-list li {
list-style: none;
display: inline;
background-image: url(../images/butn-bg.png);
}
.different-bg {
background-image: url(../images/butn-bg-1.png);
}
The HTML
<div class="my-list">
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li class="different-bg">List item 3</li>
<li>List item 4</li>
</ul>
</div>
Thanks
You just need to increase the specificity of your selector:
.my-list li {
list-style: none;
display: inline;
background-image: url(../images/butn-bg.png);
}
.my-list li.different-bg {
background-image: url(../images/butn-bg-1.png);
}
See Calculating a selector's specificity
Look my example: jsfiddle
Everything is working correctly.
Try to make more common styles, and write them as a complement changes.
Add this to your css:
.my-list .different-bg {
background-image: url(http://placekitten.com/g/200/300);
}​
If you are interested, more details can be found here: get specific css styles

How can I center the text but not the number label of an HTML ordered list

I am creating a little widget for a page that lists steps in reverse order. I plan on doing this with an ol and setting the value attribute on the individual li tags to force the numbering of the ol to be reversed. So far so good.
However, I have a design conundrum that I'm not sure can be solved with css.
With this mark up, is it possible to center the text but keep the labels left-aligned?
<ol>
<li value="5">item 5</li>
<li value="4">item 4</li>
<li value="3">item 3</li>
<li value="2">item 2</li>
<li value="1">item 1</li>
</ol>
Here is an image to illustrate the text treatment I am after.
It would be a shame if I had to shove extra spans in my markup for something that OLs do automatically.
You can reverse counters, then you can align the counters separately from the text.
not IE7 though, but with the values it'll default (IE hacks built in get back the defaults)
CSS:
ol {
padding: 0;
margin: 0;
list-style-type: decimal !ie7;
margin-left: 20px !ie7;
counter-reset:item 6; /* one higher than you need */
width: 250px;
border: 1px solid #000;
}
ol > li {
counter-increment:item -1;
text-align: center;
}
ol > li:before {
content:counter(item) ". ";
float: left;
width: 30px; background: #eee;
}
HTML
<ol>
<li value="5">item 5</li>
<li value="4">item 4</li>
<li value="3">item 3</li>
<li value="2">item 2</li>
<li value="1">item 1</li>
</ol>
You're going to need that extra element - the numbers in the list are considered part of the text for layout purposes like this. Adding an inner span set to display: inline-block should do the trick.
On a design note, it's worth pointing out that multiple lines of center-aligned text are very hard to scan, as the starting point (left edge) of the text is in a different place from line to line. Would a consistent, if large, text-indent suit you just as well? It would definitely be more readable.
And FWIW, did you know that HTML5 includes the 'reversed' attribute on OL's? You'll still need your value attributes for older browsers, of course.
I'm not sure if this is what you mean by shoving extra spans, but this works:
CSS:
li {text-align:center; margin-bottom:4px;}
#list {display:block;width:300px;background:#ddd;text-align:center;}
HTML
<ol>
<li><div id="list">This is item four</div></li>
<li><div id="list">This is item three</div></li>
<li><div id="list">This is item two</div></li>
<li><div id="list">This is item one</div></li>
</ol>
li{ list-style:none; text-align:center; }
li:before{ content:attr(value); float:left; }

text centre in <ul>

I'm building a navigation bar inside a ul. Most of the menu items have long titles so I really need to wrap them over a number of lines, as in the following code (I've inserted br/ where I'd like the returns)
<ul>
<li class="cell01on">Menu 1</li>
<li class="cell02">Menu2.1<br/>Menu2.2<br/>Menu2.3</li>
<li class="cell03">Menu 3</li>
</ul>
I'm trying to get the effect similar to using a table and vertically centring each row in it's cell. Is it possible to recreate the same in a ul?
thanks in advance
Giles
First of all if I read correctly that Menu 2.1 is a submenu then a cleaner could would be:
<ul class="menu">
<li class="active">Menu 1</li>
<li>Menu 2
<ul>
<li>Menu2.1</li>
<li>Menu2.2</li>
<li>Menu2.3</li>
</ul>
</li>
<li>Menu 3</li>
</ul>
Vertical alignment is generally hard to do in CSS outside tables, but have a look at:
http://www.student.oulu.fi/~laurirai/www/css/middle/
I tend to agree with Nux's answer, submenu's should be nested lists. As to your question about vertical centering: if you want things to behave like tables visually, you can simply use display: table;:
<style>
ul { list-style-type: none; padding: 0; display: table; }
li { display: table-cell; vertical-align: middle; }
</style>
u can add some styling like
li
{
white-space:pre-wrap;
width://set width here
text-align:center;
vertical-align:middle;
}