一个div可以有多个类(Twitter Bootstrap) [英] Can a div have multiple classes (Twitter Bootstrap)

查看:242
本文介绍了一个div可以有多个类(Twitter Bootstrap)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

div标签可以有两个类吗?



我使用twitter启动,并且有两个预定义类,我想使用。



一个是活动类,我想在下拉菜单使用


$ b

在html中处理这个的最佳方式是什么? class =h2_lin>解决方案

当然,一个div可以有你想要的任何类(这是关于bootstrap和HTML的一般):

 < div class =active dropdown-toggle>< / div> 

只要按空格分隔类。



另外:请记住,一些引导类应该用于相同的东西,但在不同的情况下(例如,您可能想要左对齐,右对齐中心,但它必须只有一个)并且你不应该一起使用它们,或者你会得到一个意想不到的结果(将发生的是,最后在css上定义的类将是应用的类)。因此,请记住,您应该避免这样做:

 < p class =text-center text-left ;一些文字< / p> 


Can a div tag have two classes?

I am using twitter bootstrap, and there are two predefined classes that I would like to use.

One is an active class that I would like to use on a dropdown-toggle within a nav bar.

What is the best way of approaching this in the html, with out overriding the css.

解决方案

Sure, a div can have as many classes as you want (this is both regarding to bootstrap and HTML in general):

<div class="active dropdown-toggle"></div>

Just separate the classes by space.

Also: Keep in mind some bootstrap classes are supposed to be used for the same stuff but in different cases (for example alignment classes, you might want something aligned left, right or center, but it has to be only one of them) and you shouldn't use them together, or you'd get an unexpected result (what will happen is that the class that's defined last on the css will be the one applied). So keep in mind you should avoid doing stuff like this:

<p class="text-center text-left">Some text</p>

这篇关于一个div可以有多个类(Twitter Bootstrap)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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