gpt4 book ai didi

javascript - 使命令栏无响应

转载 作者:行者123 更新时间:2023-11-29 11:02:14 29 4
gpt4 key购买 nike

我想将 office-ui-fabric 与 angularjs 一起使用,所以我尝试使用 ng-office-ui-fabric .

在下面example ,当屏幕宽度有限时,我们可以观察到 span(例如,3rd14)被隐藏了。这不是我想要的;无论屏幕宽度如何,我都希望它们始终显示。

有谁知道如何制作 command bar react 迟钝?

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/2.6.3/css/fabric.min.css" />
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/2.6.3/css/fabric.components.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/ngOfficeUiFabric/0.15.3/ngOfficeUiFabric.min.js"></script>
</head>
<body ng-app="YourApp">
<div ng-controller="YourController">
<uif-command-bar>
<uif-command-bar-main>
<uif-command-bar-item>
<uif-icon uif-type="save"></uif-icon>
<span>3rd</span>
</uif-command-bar-item>
<uif-command-bar-item>
<span>14</span>
<uif-icon uif-type="chevronDown"></uif-icon>
</uif-command-bar-item>
</uif-command-bar-main>
</uif-command-bar>
</div>
<script type="text/javascript">
angular.module('YourApp', ['officeuifabric.core', 'officeuifabric.components'])
.controller('YourController', function () {})
</script>
</body>
</html>

最佳答案

默认情况下,文本设置为不在 css 中显示。即:

CommandBarItem .ms-CommandBarItem-commandText {
display: none;
}

然后他们使用媒体查询仅在宽度超过 640px 时显示这些元素即:

@media only screen and (min-width: 640px)
fabric.components.min.css:6
.ms-CommandBarItem .ms-CommandBarItem-chevronDown, .ms-CommandBarItem .ms-CommandBarItem-commandText {
display: inline;
}

您可以通过提供您自己的不使用媒体查询的样式来覆盖他们的样式,并且只需确保您的 css 在他们的 css 之后加载(因此它优先)。即:

 CommandBarItem .ms-CommandBarItem-commandText {
display: inline;
}

这是一个示例应用程序,演示了这一点。请注意,我必须在 style 标记 b/c 中内联地添加 head 标记中的样式,以说明内联编辑器如何加载其 Assets 。通常,您只需在 link 标记中加载您自己的自定义 css(确保它是最后加载的)。

<!DOCTYPE html>
<html>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/2.6.3/css/fabric.min.css" />
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/2.6.3/css/fabric.components.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/ngOfficeUiFabric/0.15.3/ngOfficeUiFabric.min.js"></script>

<style>
.ms-CommandBarItem .ms-CommandBarItem-chevronDown,
.ms-CommandBarItem .ms-CommandBarItem-commandText {
display: inline;
}
</style>
</head>

<body ng-app="YourApp">
<div ng-controller="YourController">
<uif-command-bar>
<uif-command-bar-main>
<uif-command-bar-item>
<uif-icon uif-type="save"></uif-icon>
<span>3rd</span>
</uif-command-bar-item>
<uif-command-bar-item>
<span>14</span>
<uif-icon uif-type="chevronDown"></uif-icon>
</uif-command-bar-item>
</uif-command-bar-main>
</uif-command-bar>
</div>
<script type="text/javascript">
angular.module('YourApp', ['officeuifabric.core', 'officeuifabric.components'])
.controller('YourController', function() {})
</script>
</body>

</html>

这就是我想出来的。使用 chrome 开发工具,我用鼠标右键单击文本并选择检查。这显示了元素和与之关联的样式。默认样式是应用display: none;。当您将浏览器调整到超过 640 像素宽时,您会看到正在应用的媒体查询现在显示为 display: inline; 元素。

enter image description here

关于javascript - 使命令栏无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45131835/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com