2012-09-17 34 views
9

不确定这是否可行。我认为Twitter Bootstrap标题太大了。 h136px; h230px,依此类推。按比例降低twitter引导标题大小

有没有什么办法可以按比例缩小标题大小?假设我只想每个标题的90%。我不想一一列出每个标题的字体大小。

谢谢。

+1

我相信引导程序会设置一个baseFontSize变量,几乎所有的字体大小属性都是相对的,例如:font-size:@baseFontSize * 2;你可以把它改成更小的东西。 – Mark

回答

0

给一个类的body,让这个CSS:

body.myClass h1, 
body.myClass h2, 
body.myClass h3, 
body.myClass h4, 
body.myClass h5, 
body.myClass h6 {font-size: 0.9em;} 

这给你90%的原始大小。你也可以把它作为90%。 :)

+1

我相信,那就是.9em或90%的body base font size,而不是在CSS中声明的h1 font-size属性。 – Mark

+0

@Mark,TBS声明'h1 {font-size:36px;}',我们不能将它覆盖为原始的90%的.myClass h1 {font-size:0.9em;}'。它的作品正确吗? –

+1

我的担心是我认为它不是原始的,而是它的继承字体大小。 DOM中具有明确字体大小的正文或父元素的字体大小。 – Mark

5

这将是很好,如果这是可能的调整一个变量在LESS,但我不认为它是。

variables.less

// Typography 
// ------------------------- 
@sansFontFamily:  "Helvetica Neue", Helvetica, Arial, sans-serif; 
@serifFontFamily:  Georgia, "Times New Roman", Times, serif; 
@monoFontFamily:  Monaco, Menlo, Consolas, "Courier New", monospace; 

@baseFontSize:   14px; 
@baseFontFamily:  @sansFontFamily; 
@baseLineHeight:  20px; 
@altFontFamily:   @serifFontFamily; 

@headingsFontFamily: inherit; // empty to use BS default, @baseFontFamily 
@headingsFontWeight: bold; // instead of browser default, bold 
@headingsColor:   inherit; // empty to use BS default, @textColor 

所以,你可以通过改变@baseFontSize规模文本的所有,但遗憾的是没有单独的@baseHeaderFontSize。你总是可以分解这个项目!

编辑2:正如@merv指出的,标题大小将基于@baseFontSizefrom 2.1.2

原创编辑:实际上,它看起来像标题大小反正硬编码:type.less

h1 { font-size: 36px; line-height: 40px; } 
h2 { font-size: 30px; line-height: 40px; } 
h3 { font-size: 24px; line-height: 40px; } 
h4 { font-size: 18px; line-height: 20px; } 
h5 { font-size: 14px; line-height: 20px; } 
h6 { font-size: 12px; line-height: 20px; } 
+0

我猜OP是使用纯CSS。 :) –

+1

然后他应该切换到LESS。 :) – RichardTowers

+0

事实上,即使在普通的CSS,如果这是一个变量OP可以建立一个[自定义引导](http://twitter.github.com/bootstrap/customize.html#variables)与变量设置为他们希望。这不是一个变量。 – RichardTowers

6

我意识到这线程现在已经过去18个月大,但万一有人遇到此同样,引导(V3.1.1)的最新版本拥有所有标题的字体大小的设置less/variables.less,就像这样:

@font-size-h1: floor((@font-size-base * 2.6)); // ~36px 
@font-size-h2: floor((@font-size-base * 2.15)); // ~30px 
@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px 
@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px 
@font-size-h5: @font-size-base; 
@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px 

所以它只是调整的乘数为每这些有的情况下,一个影响。

+0

'解决方案:'用单个支架替换双托架。这是我认为的一个错误。 –

+0

@ B.Martin上面的代码是bootstrap less/variables.less文件中的代码片段,并非我写的代码。即使在最新版本v3.3.6(非sass)中,代码也是一样的。 – alexkb