Reputation: 480
In a GWT web application, I want to give the opportunity to my users to decrease or increase font size in the current page.
Is it possible, in GWT, to do this, if the user click on + button:
body { font-size: 150%; }
And to do this, if the user click on - button:
body { font-size: 50%; }
Thanks!
Upvotes: 0
Views: 1666
Reputation: 7988
Please try following:
Document.get().setStyleAttribute("font-size", "150%");
If you need to modify styles of particular style classes, then you should query them first somehow. (with native JS or http://code.google.com/p/gwtquery/ for example) Then iterate them and modify style attributes
DOM.setStyleAttribute(someGwtElement.getElement(), "font-size", "150%");
Upvotes: 0
Reputation: 2389
This works for a CSS inline solution. Replace CLASSNAMEHERE
to suit your needs, or pass it as a parameter of the function.
private static native void changeFontSize(int inc)/*-{
{
var p = $doc.getElementsByClassName('CLASSNAMEHERE');
for (n = 0; n < p.length; n++) {
if (p[n].style.fontSize) {
var size = parseInt(p[n].style.fontSize.replace("px", ""));
} else {
var size = 11;
}
p[n].style.fontSize = size + inc + 'px';
}
}
}-*/;
Upvotes: 1