【问题标题】:How to remove hover properties from WinJS ListView?如何从 WinJS ListView 中删除悬停属性?
【发布时间】:2016-11-25 14:42:11
【问题描述】:

我正在使用 WinJS 开发一个 Windows 通用应用程序,但要对其进行自定义非常具有挑战性,我需要遵循一些设计说明。

当我尝试从列表元素中删除悬停属性时,就会出现问题。当我的鼠标悬停在项目上时,div 的背景会变暗。我试图用

删除它
.win-listview .win-container:hover{
     background-color: transparent;
}

还有

.win-selectionbackground {
    opacity: 0;
}

但它不起作用。

这里有一些代码可以帮助你:

<!-- TEMPLATES -->
<div class="storyPhotoTemplate" data-win-control="WinJS.Binding.Template" style="display: none">
    <div class="story-photo-icons">
        <div style="height: 250px; width: 22px;position:relative; float: left;">
            <img class='xButton smaller' src = '../../images/x-icon.png' />
        </div>
        <div class="pic-area">
            <img src="#" class="story-photo" data-win-bind="src: image" />
        </div>

    </div>
</div>

<section class="gallery">
    <div class="button lBtn"></div>
    <!-- CONTENT -->
    <div id="storyPhotoGrid"
         class="win-selectionstylefilled"
         data-win-control="WinJS.UI.ListView"
         data-win-options="{
            itemDataSource: Photos.StoryGrid.dataSource,
            itemTemplate: select('.storyPhotoTemplate'),
            selectionMode: 'none',
            tapBehavior: 'none',
            layout: { type: WinJS.UI.GridLayout, orientation:'horizontal' }
    }">
    </div>

框架构建的DOM树并不明显。如果有人需要更多信息,请告诉我,我会更新问题。

【问题讨论】:

    标签: javascript html css uwp winjs


    【解决方案1】:

    ListView 项的悬停行为在

    中定义
    html.win-hoverable .win-selectionstylefilled .win-container:hover .win-itembox,
    html.win-hoverable .win-selectionstylefilled.win-container:hover .win-itembox 
    {
      background-color: rgba(255, 255, 255, 0.1);
    }
    

    您可以在 WinJS lib 的 ui-light.cssui-dark.css 文件中找到它,具体取决于您使用的主题。

    因此,如果您想禁用悬停时的背景颜色,请更改如下样式:

    html.win-hoverable .win-selectionstylefilled .win-container:hover .win-itembox,
    html.win-hoverable .win-selectionstylefilled.win-container:hover .win-itembox 
    {
      background-color:transparent;
    }
    

    【讨论】:

    • 非常感谢!我想补充一点,我是在另一个文件中完成的,所以我可以保留 WinJS 文件的原样,并用在它们之后加载的自定义 css 文件覆盖它们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 2019-12-14
    相关资源
    最近更新 更多