“使用 javascript 动态调整文本大小”到底是什么?意思是
我刚刚完成并交了一份家庭作业,其目标是“使用 JavaScript 样式动态调整文本大小”。我们有一些带有特定类别的段落,这些是我们应该调整大小的段落。
现在,如果您的 CSS 文件显示文本为 X 尺寸,那么当页面加载时,您可以使用 JavaScript 来获取该值并获取该值。让它变大。这会被认为是动态改变大小吗?
事实证明,老师真正想要的是在调整窗口大小时更改文本大小,但他实际上要求的似乎是开放式的。
只是想了解什么是动态调整大小。
感谢您的任何见解。
function setGreekSize() // change the height of text w/ 'greek' class
{
var currentSize = parseInt($("#content").css("font-size"))*1.2;
$(".greek").css("font-size", currentSize+"px");
}
当文档准备好时,我将其放在一个函数中。我知道这有点毫无意义,但他说不要对家庭作业过于“花哨”。
I just finished and turned in a homework assignment where the goal was to 'dynamically resize text with JavaScript styles'. We had a few paragraphs with a certain class on them, and those were the ones we were supposed to resize.
Now, if you a CSS file that says the text is X size, and then when the page loads you use JavaScript to get that value & make it larger. Would that be considered dynamically changing the size?
What it turns out the teacher actually wanted was to change the text size when the window is resized, but it seems what he actually asked for was pretty open ended.
Just trying to get an idea of what qualifies as dynamic resizing.
Thanks for any insight..
function setGreekSize() // change the height of text w/ 'greek' class
{
var currentSize = parseInt($("#content").css("font-size"))*1.2;
$(".greek").css("font-size", currentSize+"px");
}
I had that in a function for when the document was ready. Somewhat pointless, I know, but he said not to try to get too 'fancy' with the homework assignment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
动态调整大小是根据事件或操作调整文本大小...它是一种大小,然后由于事件而更改。我认为,在页面加载后调整其大小可能是有效的,但用户如何知道原始字体是什么以及新字体是什么?唯一知道它是动态的人是开发人员。是的,如果背后有一些逻辑或推理就好了。我会更改您的示例以添加一个计时器,这样用户可以看到原始大小,并在几秒钟后发生变化。也许用户单击一个按钮,文本就会增长......
您需要示例代码吗?
Dynamic resizing is resizing the text based on an event or action... It was one size then changed due to event. I would argue that resizing it once the page loads may be valid but how would the user know what the original font was and what the new font is? the only person who knows it is dynamic is the developer. Yes if there was some logic or reasoning behind it fine. I would change your example to add a timer that way the user can see the original size and after a few seconds it changes. Ir maybe the user clicks a button and the text grows...
Do you need sample code?