Can span.classname css be applied on div.className
Is there any way to use this css definition for div element
span.classsName{
width:100px;
}
for example
<div class="classsName"></div>
will not work, but you see what I am trying to achieve.开发者_JS百科
Thanks.
Call it .className{ }
without the span, and you can use it on any field.
You could remove the span
to just leave .classsName
, which will then be applied to any element with that class name, regardless of tag name.
Alternatively, you could change the selector to span.classsName, div.classsName
to apply to both span
and div
elements with that class.
How about
.classsName{
width:100px;
}
or
span.classsName, div.className {
width:100px;
}
You could do (just remove the span
):
.classsName{
width:100px;
}
The .xxxx
CSS naming applies to HTML elements whose class
matches CSS xxxx
name. Alternatively:
span.className, div.className {
width: 100px;
}
Which means that the div
and span
with the class className
will have the same width.
精彩评论