Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

css - Have text scale up in size to fit the container

Using CSS, and specifically no onload javascript, would it be possible to do this:

You have a cell of 150px wide and 100px in height. It contains a text, e.g.: $20,00 or any variant of that.

You want it to perfectly fit the size of the container.

I'd be able to do it with javascript, size up the text until a container without padding/margin reaches the cell's width and/or height. Or contain it in something that has an overflow set to auto and see when it overflows or something.

Can it be done with pure CSS?

Take into account that the font isn't a fixed size font, either. Use Arial if you like.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Check this out: http://css-tricks.com/viewport-sized-typography/

Unfortunately this only works in Chrome 20+ & IE 10+ so for now you'll have to stick with a js solution....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...