2014-03-25 66 views
0

我正在嘗試一個小時,並且我無法在某些列(引導程序)內製作字體大小。這是一個fiddle,顯示發生了什麼。無法創建字體大小響應

有沒有什麼方法可以讓我做出迴應?

下面是我使用,使其響應的CSS:

@media only screen and (max-width: 450px) { 
    .digit { 
     font-size: 1em; 
    } 
} 

但它不工作。 :/

+0

在我看來,你的字體尺寸不斷縮小,但與頁面大小縮放。這是你的最終目標嗎?字體大小爲300像素不是400像素? –

+2

除非父/主體/根字體大小也更改,否則1em的大小始終相同。 –

+0

@EricHolmes我希望它隨着屏幕的縮小而相應縮小,但這很奇怪。我想解決這個問題:'( –

回答

1

我做了一個插件是:https://github.com/kagagnon/Responsive-Font

一旦你有它,你必須設置查詢點在JavaScript:

{ 
    queryPoint : font-size 
} 

例如:

rf('.digit').setQueryPoint({ //rf() = CSS selector. 
    450 : 12, 
    1500 : 40 
}) 

http://jsfiddle.net/Pm2nh/5/

當然,您需要調整滿足您需求的價值。

+0

你能把這個圖像中的所有文字都帶上嗎?這就是我的意思是「迴應」。請幫忙。 –

+0

那麼,你只需要調整你的CSS,但現在對我來說這太複雜了。 –

+0

如果OP利用'media-queries'(和'em'),我不認爲插件是必要的。 –

0

如果您只擔心現代瀏覽器(大多數移動瀏覽器屬於哪個瀏覽器),則可以使用「視口寬度」(vw)度量。這是視口(設備)寬度的百分比。示例使用3%的視口寬度。調整窗口大小並再次點擊運行。

http://jsfiddle.net/KA5qQ/

欲瞭解更多信息,請查看我們上Chris Coyier's blog post

<div id="myDiv"> 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
</div> 

CSS

#myDiv { 
    font-size: 3vw; 
}