在一个元素上使用两个CSS类 [英] Using two CSS classes on one element

查看:173
本文介绍了在一个元素上使用两个CSS类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里做错了什么?

我有一个 .social div ,但在第一个,我想在顶部零填充,而在第二个,我想没有底部边框。

I have a .social div, but on the first one I want zero padding on the top, and on the second one I want no bottom border.

为第一次和最后一次创建类,但我认为我在某个地方错了:

I have attempted to create classes for this first and last but I think I've got it wrong somewhere:

.social {
    width: 330px;
    height: 75px;
    float: right;
    text-align: left;
    padding: 10px 0;
    border-bottom: dotted 1px #6d6d6d;
}

.social .first{padding-top:0;}

.social .last{border:0;}

和HTML

<div class="social" class="first">
    <div class="socialIcon"><img src="images/facebook.png" alt="Facebook" /></div>
    <div class="socialText">Find me on Facebook</div>
</div>

我猜不可能有两个不同的类?

I'm guessing it's not possible to have two different classes? If so how can I do this?

推荐答案

如果你想在一个元素上有两个类,可以这样做:

If you want two classes on one element, do it this way:

<div class="social first"></div>

在css中引用它:

.social.first {}

示例:

https://jsfiddle.net/tybro0103/covbtpaq/

这篇关于在一个元素上使用两个CSS类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆