AppDevGuy
04-30-2009, 08:47 PM
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.
It is easy enough to pop up lists. The problem comes from having only one item with a style and other items with other styles. I've coded up a bunch of li items I've also tried it with div and
display: list-item;
list-style-type:disc;
in one CSS entry (called itemselected) and then another CSS entry with
display: list-item;
list-style-type:none;
called itemnotselected in all the other items. I use Javascript click events to change which item has the class="itemselected" and make all the other items have class="itemnotselected".
I've also tried showing the dot with
list-style-image: url(images/dot.gif) ! important;
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 works. My Javascript executes and changes which elements have which classes assigned to them. 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.
Here's part of the CSS. Note that part of it is commented out since it represents different ways I've tried to make it work. Basically, on a click I just change which li or div (and which a element within them) has the itemselected or itemnotselected.
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;
}
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.
It is easy enough to pop up lists. The problem comes from having only one item with a style and other items with other styles. I've coded up a bunch of li items I've also tried it with div and
display: list-item;
list-style-type:disc;
in one CSS entry (called itemselected) and then another CSS entry with
display: list-item;
list-style-type:none;
called itemnotselected in all the other items. I use Javascript click events to change which item has the class="itemselected" and make all the other items have class="itemnotselected".
I've also tried showing the dot with
list-style-image: url(images/dot.gif) ! important;
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 works. My Javascript executes and changes which elements have which classes assigned to them. 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.
Here's part of the CSS. Note that part of it is commented out since it represents different ways I've tried to make it work. Basically, on a click I just change which li or div (and which a element within them) has the itemselected or itemnotselected.
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;
}