这是解决方案。
的HTML:
<h1>Introduction to the DOM</h1>
<p class="test">There are a number of reasons why the
DOM is awesome, here are some:</p>
<ul>
<li id="everywhere">It can be found everywhere.</li>
<li class="test">It's easy to use.</li>
<li class="test">It can help you to find what you want, really quickly.</li>
</ul>
JavaScript:
var li = document.getElementsByTagName("li");
for ( var i = 0; i < li.length; i++ ) {
li[i].onmouseover = function() {
this.style.backgroundColor = 'lime';
this.style.borderLeft='5px solid red';
this.style.listStyle = 'square';
};
li[i].onmouseout = function() {
this.style.backgroundColor = 'white';
this.style.borderLeft='';
this.style.listStyle = 'disc';
};
}
CSS:
ul li {line-height:30px; padding-left: 10px; border-left:5px solid transparent;}
#element {
background: linear-gradient(top, black 0%, white 100%);
}
希望这可以帮助。