繁体   English   中英

用户如何在SharePoint中手动增加或减少页面中所有内容的字体大小?

[英]How a user can manually increase or decrease font size of all the content in a page in SharePoint?

我有一个要求,用户可以使用链接或按钮单击来增加(A +)或减少(A-),以影响SharePoint页面中整个内容的字体大小。 我将SharePoint Online(Office365)用于POC。 我尝试将内容编辑器Webpart与html和js结合使用:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$('button').click(function()
{
var theElement = $("div").css("font-size");
var textSize = parseFloat(theElement, 10);
var unitOfMeasurement = theElement.slice(-2);

if ( (this).id == "largerTextLink")
{
textSize += 2;
}
else
{
textSize -= 2;
};

$('div').css("font-size", textSize + unitOfMeasurement);

return false;
});
});
</script>
<body>
<div class="font-button">
<button id="smallerTextLink">Smaller Text</button>

<button id="largerTextLink">Larger Text</button>
</div>
</body>

但是上面的代码没有反映任何内容,只是页面被刷新了。 作为初级开发人员,我不知道我是否走了正确的道路。 有什么方法或替代方法可以解决此要求?

您可以为此使用em

这是一个类似问题的很好的答案/示例: https : //stackoverflow.com/a/16461139/3021549

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM