使用Bootstrap和我自己的CSS [英] Using Bootstrap and my own CSS together

查看:178
本文介绍了使用Bootstrap和我自己的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道基本的CSS,但我没有经验。
我想使用bootstrap的CSS文件,但我想添加自己的样式代码。我该怎么办?
我应该先添加Bootstrap样式,然后我的?

I know basic CSS, but I'm not experienced. I want to use bootstrap's CSS file, but I want to add my own style codes too. What should I do for that? Should I add Bootstrap styles first and then mine? Is that the best way?

推荐答案

你将有这样的样式表顺序,首先你将包括bootstrap css,然后你的样式表文件。这是为什么?因为这样你可以覆盖框架中的类,而不使用!important。您可以编写自己的类并将它们包括在布局中,您可以使用引导类,并根据需要对它们进行调整。当你混合你的类和引导类检查什么属性从他们的类添加,你需要他们或不是... ...

You will have the stylesheets order like this, first you will include bootstrap css, then your stylesheet file. Why is that? Because that way you can overwrite the classes from the framework without using !important. You can write your own classes and include them in your layout, you can use bootstrap classes and make adjustments to them as you need. When you mix your classes and bootstrap classes check what attributes are added from their classes, do you need them or not etc...

示例

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<style>
  /* Your external css file will go here. This is just for testing :) */
  
.mycustombtn{
  background: #000;
}

</style>  


<button type="button" class="btn btn-danger mycustombtn">Danger</button>

这篇关于使用Bootstrap和我自己的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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