我有一个HTML未排序列表,可以捕获其“单击时”事件。单击列表项时,我想将该项目的字体设置更改为粗体,以便用户获得已被选中的视觉指示。这可能吗?
我需要在我的代码中重复十次这个内容,然后我认为这可能在一个循环中像一个for或while,但我试过,我不能
<li>
<img style="float: left;" src="img/gaja.jpg" alt="Angry face" />
<div style="width: 100px; height: 20px; float:left; margin-left: 5px; font: bold 12px arial;">IceMan</div>
<div style="width: 150px; height: 20px; float:left; margin-left:5px;">Web Designer / FullTime</div>
</li>
Run Code Online (Sandbox Code Playgroud)
任何帮助?
谢谢
当用户点击菜单选项卡时,我希望它保持选中状态,并带有白色按钮.
这是我的尝试,但它不起作用.如果你点击主页按钮它不会保持白色.
HTML
<ul id="navigation">
<li><a href="#"><span>HOME</span></a></li>
<li><a href="/en-us/about.aspx"><span>ABOUT</span></a></li>
<li><a href="/en-us/contact.aspx"><span>CONTACT</span></a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS:
body{
background-color:orange;
}
#navigation a
{
background: url("http://i52.tinypic.com/spxfdw.png") no-repeat scroll 0 0 transparent;
color: #000000;
height: 43px;
list-style: none outside none;
padding-left: 10px;
text-align: center;
text-decoration: none;
width: 116px;
}
#navigation a span
{
padding-right: 10px;
padding-top: 15px;
}
#navigation a, #navigation a span
{
display: block;
float: left;
}
/* Hide from IE5-Mac \*/
#navigation a, #navigation a span
{
float: none
}
/* End hide …Run Code Online (Sandbox Code Playgroud) 我在IE 7中有一个列表元素缩进的非常问题.填充左边似乎没有任何影响.我的HTML在这里http://pastebin.com/0TXXN3AZ.(列表元素应该是左侧的简单导航.)css是
ul.navigation{
width: 230px;
padding-left:2px;
display: block;
float: left;
}
ul.navigation li{
padding-left:2px;
list-style: none;
}
ul.navigation li a{
padding-left: 2px;
display:inline-block;
}
ul.navigation li ul{
padding-left:2px;
list-style: none;
}
#content{
margin-left: 260px;
padding-right: 50px;
font-size: 0.9em;
}
Run Code Online (Sandbox Code Playgroud)
在其他浏览器中,一切看起来都符 在IE 7中,打算将列表项扩展到内容区域.有任何想法吗?
提前致谢,
安德烈亚斯
我正在尝试使用JavaScript创建一个li并将其附加到现有的ol.我正在使用的代码是
<ol id=summaryOL>
</ol>
function change(txt) {
var x=document.getElementById("summaryOL");
newLI = document.createElementNS(null,"li");
newText = document.createTextNode(txt);
newLI.appendChild(newText);
x.appendChild(newLI);
}
change("this is the first change");
change("this is the second change");
Run Code Online (Sandbox Code Playgroud)
这些应该是这样的:
1. this is ...
2. this is ...
Run Code Online (Sandbox Code Playgroud)
但看起来像:
this is the first changethis is the second change
Run Code Online (Sandbox Code Playgroud)
我创造了一个小提琴:小提琴.谢谢你的帮助.
这种情况发生在以下标记中:
<ul id="sideMenu" class="menuFontStyle">
<li class="category">Test</li>
<ul class="secondLevel" style="display: none;">
<li></li>
</ul>
...
Run Code Online (Sandbox Code Playgroud)
在FF和Chrome中,内部UL正在被接收,但IE7似乎正在跳到下一个li.什么可以作为一种解决方法?这是一个自定义手风琴脚本.
是否可以从最后一个号码开始制作有序列表(ol)?对于前者
5 - sasasasa
4 - sasasas
3 - sasasas
2 - sasasa
1 - sasasas
我已经看过有没有一种简单的方法可以改变列表中子弹的颜色?.这个问题的答案对我没有帮助,因为我无法控制HTML结构.这适用于CSS库,而不是特定的网页或站点.
假设我有以下代码:
<style>
* {
background-color: white;
color: black;
}
#too {
background-color: black;
color: white;
}
</style>
<ol>
<li id="won">Item 1</li>
<li id="too">Item 2</li>
<li id="tre">Item 3</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
应该通过反转背景和前景色来突出显示第二个列表元素,但是在这种情况下,在这种情况下,项目的编号也会改变.
有什么方法可以做到这一点,同时保持第2项的数字是它的初始颜色?我已经看到了使用::before伪元素和contentCSS属性的解决方案,但这些解决方案不适value用于li元素的HTML5 属性.
无论你给出什么答案,它应该是当前CSS3的语义.这是因为最终实现将用于:target突出显示目标元素,因此无法保证HTML结构.
我必须删除一个带有空ul标签的div.
编辑:ul标签不为空,它有一堆空格.
我想用jQuery做到这一点
这是我到目前为止:
$('trim(#menu):empty').parent().remove();
Run Code Online (Sandbox Code Playgroud)
我的div的id是'menu'.
例:
之前:
<div id="container>
<div id="menu">
<ul>
</ul>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
后:
<div id="container>
</div>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
斯泰恩
我找到了很多答案,但在我的案例中都没有.这是我的jsfiddle.如何去除点?
以下是我所有尝试的基础:
ol {
counter-reset: item;
display: inline-block;
list-style-type: none;
}
Run Code Online (Sandbox Code Playgroud)