Как я могу применить блок стиля CSS к нескольким различным классам? Например, я имею
<div class="foo">...</div>
<div class="bar">...</div>
...
.foo .bar ??? // This selector should apply to both classes
{
font-size:50%;
...
}
Используйте запятую:
.foo, .bar {
....
}
Обратное, нанесение нескольких классов до одного элемента также возможно:
<html>
<head>
<style type="text/css">
.foo {
}
.bar {
}
</style>
</head>
<body>
<!--
space separated list of classnames
to apply multiple css classes to a single element.
-->
<div class="foo bar">...</div>
</body>
</html>