I have a situation here which I could not resolve.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<he开发者_如何学Pythonad>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page Title</title>
<style type="text/css">
#midcol ul {
padding-left: 25px;
}
.mylist ul {
padding-left: 5px;
}
</style>
</head>
<body>
<div id="midcol">
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<div class="mylist">
<ul>
<li>Item 3</li>
<li>Item 4</li>
</ul>
</div>
</div>
</body>
</html>
How do I override the padding style of midcol to my lists of class mylist? It's currently taking the style of midcol and is ignoring the style defined for mylist.
You can change:
#midcol ul {
padding-left: 25px;
}
to:
#midcol > ul {
padding-left: 25px;
}
That should do it.
Nest the styles:
#midcol .mylist ul {
padding-left: 5px;
}
精彩评论