Jump to content

Resizing text relative to page resolution in html & css?

Goredoth

I'm having a hard time getting the font to play nicely with the re-sizing the page of the website I'm making.

What I really want is the text to resize like the image behind them when I set it at a % but I can't seem to do that with text.

 

Yeah I'm pretty rubbish at this stuff.

 

Would really appreciate the help.

Link to comment
Share on other sites

Link to post
Share on other sites

You can scale font-size relative to the viewport size using the CSS3 units vwvh, vmin, and vmax.

 

A single viewport width (vw) or height (vh) unit is == 1% of the viewport width or height, respectively.

 

So in this example,

span{     font-size: 50vw;} h2{    font-size: 1vh;}

all span tags would have a font-size equal to 50% of the viewport width (quite extreme...) and h2 tags would have a font-size equal to 1% of the viewport height.

 

From Opera's Dev site, here are the very short descriptions for all four units:

1vw: 1% of viewport width1vh: 1% of viewport height1vmin: 1vw or 1vh, whatever is smallest1vmax: 1vw or 1vh, whatever is largest

Keep in mind that according to CanIUse, iOS and IE all have limited support for these new units, as with most new CSS3 features.

Link to comment
Share on other sites

Link to post
Share on other sites

If you're having the aforementioned compatibility issues, it's easy enough to use javascript to control this

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

Awesome, thanks I will give that a shot.

 

Appreciate the help guys.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×