Jesus Cuevas
Jesus Cuevas

Reputation: 57

JavaScript Resize Font

var ref = document.getElementById("ref");
var bio = document.getElementById("bio");
var size = 0.1;
bio.style.fontSize = "0.1vw";
while(ref.style.height < bio.style.height) {
    size += 0.1;
    bio.style.fontSize = concat(toString(size), 'vw');
}

Hi, I'm trying to get this script to work so that the font-size of div "bio" makes its height equal to or just larger than the height of a div next to it, "ref". The code above does not work. Can you help me, thanks.

Upvotes: 1

Views: 40

Answers (1)

Cameron637
Cameron637

Reputation: 1719

Use fontSize instead of font-size. That's how the Javascript properties are written. Like this:

bio.style.fontSize = ...

And any other styling that would normally have a dash in css is camelCase in Javascript

Upvotes: 1

Related Questions