I want to make a pop-out list that shows multiple items where only one of those items has a bullet next to it. The best way to described what I want to do in HTML is by example: In Firefox you can click
View | Character Encoding | Auto-Detect
That brings up a side list of several items. Only one of those items has a solid dot next to it that shows it is the selected item. You can click to change which item has the bullet next to it. I want to know how do the same thing with HTML, CSS, and Javascript.
I've made attempts at doing this using either div or li for the items. I think my problem is in the CSS for those items. I use Javascript to change which single item on the list has a class attribute for the item that gets the bullet. The item that gets the bullet gets a class called itemselected and the other items all get a class called itemnotselected. You can see the CSS for those below.
Note that some of the properties are commented out. That's because I've tried variations to see if I can get it working right.
My problems are with:
- getting the dot onto the left of the text description of a single item,
- align the dot vertically with the text description,
- get all other row text descriptions aligned the same vertically.
- Getting the dot within the colored background box that has the text description from within the a tag.
I'm using an "a" tag within an "li" (or within "div" on some variations I've tried) in order to get the onclick. That part of it works. My Javascript executes and changes which elements have which classes assigned to them. I then see changes in the displayed list that indicate I've changed which row has class="itemselected".
My problem is in layout appearances. I'm testing with IE 7, latest Firefox, Seamonkey, Safari. All have similar problems but IE is worse than the others.
li.itemselected, a.itemselected, div.itemselected
{
display: list-item;
list-style-type:disc;
/* background-image: url(images/dot.gif); */
/* background-image: url(images/arrow.png); */
list-style-image: url(images/dot.gif) ! important;
/*list-style-image: none; */
/*list-style-position:inside;*/
background-repeat: no-repeat;
/*padding-left:6px; */
margin-left: 15px;
/*background-position: 0 .5em; */
background-position: left center;
/*background-color: #b041d3;*/
background: #b041d3 none;
font-size: 9pt;
z-index:4;
}
/*
li.itemselected li:before {
background: #b041d3 none ! important;
padding-left:6px;
margin-left: 15px;
content: "\00BB \0020";
z-index:4;
}
li.itemnotselected li:before {
background: #b041d3 none ! important;
padding-left:6px;
margin-left: 15px;
content: "▶ \0020";
z-index:4;
}
*/
li.itemnotselected, a.itemnotselected, div.itemnotselected
{
display: list-item;
list-style-type:square;
/*list-style-type: none; */
/*border-left-width:thick;*/
/*padding-left:6px; */
margin-left: 15px;
/*background-position: 0 .5em; */
background-position: left center;
/*color: #746C19;*/
background-color: #f0e1a3 ! important;
font-size: 9pt;
z-index:4;
}