开发者

Can span.classname css be applied on div.className

开发者 https://www.devze.com 2023-04-03 04:52 出处:网络
Is there any way to use this css definition for div element span.classsName{ width:100px; } for example

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号