【问题标题】:How a user can manually increase or decrease font size of all the content in a page in SharePoint?用户如何手动增加或减少 SharePoint 页面中所有内容的字体大小?
【发布时间】:2018-02-16 19:56:19
【问题描述】:

我有一个要求,用户可以使用链接或按钮单击来增加 (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>

但上面的代码没有反映任何内容,只是刷新了页面。作为一名初级开发人员,我不知道我是否走在正确的道路上。 有没有办法或替代方案来解决这个要求?

【问题讨论】:

    标签: javascript sharepoint font-size


    【解决方案1】:

    您可以为此使用em

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

    【讨论】:

    • 感谢您的回复。我的问题与 SharePoint 有关。我可以使用内容编辑器 webpart 还是有其他方法可以使用您在链接中提到的 javascript 或 css?
    • 抱歉,我对自定义 SharePoint 页面不太熟悉。我认为你可以做一些事情,比如将body font-size 指定为1.0em#smallerTextLink 指定为1.5em 并使用javascript 增加font-size。如果有帮助,这里有一个例子:jsfiddle.net/km4wnm90/6
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-30
    • 2013-03-29
    • 2020-01-21
    • 1970-01-01
    相关资源
    最近更新 更多