c# - Facebook 喜欢 Ext3 按钮的通知图标

标签 c# asp.net css extjs ext.net

我正在使用一个 Ext 工具栏,它有一个名为“NotificationButton”的按钮,我计划在该按钮上显示数字,就像在 facebook 通知中一样。我可以成功更改按钮的 html。我唯一被卡住的是 css 部分。

谁能指出我正确的方向?提前致谢。

已编辑!

根据 Daulet 的建议,在这一点上,我有:

样式表

<style type="text/css">
    .fbNotification
    {
        background: none repeat scroll 0 0 orange!important;
        border: 1px solid orange !important;
        border-radius: 10px !important;
        width: 18px !important;
    }

    .fbNotification .x-tip-body
    {
        font-size: 10px !important;
    }
</style>

标记

<ext:Panel ID="Panel1" runat="server" Title="Panel with toolbars" Width="600" Height="300">
    <TopBar>
        <ext:Toolbar runat="server">
            <Items>
                <ext:Button ID="b1" runat="server" Icon="Add" StandOut="true" Text="Notifications">
                    <Listeners>
                        <Render Fn="createTooltp"></Render>
                    </Listeners>
                </ext:Button>
                <ext:ToolbarFill />
                <ext:Button runat="server" EnableToggle="true" ToggleGroup="G1" Icon="GroupAdd" Pressed="true" />
                <ext:Button runat="server" EnableToggle="true" ToggleGroup="G1" Icon="GroupDelete" />
                <ext:Button runat="server" EnableToggle="true" ToggleGroup="G1" Icon="GroupEdit" />
            </Items>
        </ext:Toolbar>
    </TopBar>
</ext:Panel>

脚本:

<script type="text/javascript" language="javascript">
    function createTooltp(cmp) {
        tooTip = new Ext.ToolTip({
            anchor: 'left',
            target: cmp,
            html: '10',
            cls: 'fbNotification',
            autoRender: true,
            renderTo: Ext.getBody(),
            autoHide: false,
            shadow: false,
            padding: 0,
            width: 16,
            shrinkWrap: 0,
            anchorToTarget: true,
            mouseOffset: [-4, -8]
        });

        tooTip.show();
    }
</script>

enter image description here 现在的问题是css没有正确应用。请帮忙!

最佳答案

好的,这里是 Ext.NET 1.x 的版本。您唯一需要做的就是创建自己的提示 anchor Sprite 图像,您可以使用任何浏览器开发工具获得它:

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ext.NET Examples</title>
    <style>
        .fbNotification
        {
            background: none repeat scroll 0 0 orange!important;
            border: 1px solid orange !important;
            border-radius: 10px !important;
            width: 18px !important;
        }

        .fbNotification .x-tip-body
        {
            font-size: 10px !important;
        }

        .fbNotification .x-tip-ml {
            background: none;
            padding-left: 3px !important;            
        }

        .fbNotification .x-tip-tc, .fbNotification .x-tip-tl, .fbNotification .x-tip-tr, .fbNotification .x-tip-bc, .fbNotification .x-tip-bl, .fbNotification .x-tip-br, .fbNotification .x-tip-ml, .fbNotification .x-tip-mr 
        {
            background: none;
        }

        .fbNotification .x-tip-anchor 
        {
            /* Put here your own gif image of tip anchor sprite */
            background-image: none; 
        }
    </style>

    <script>
        function createTooltp(cmp) {
            var tooTip = new Ext.ToolTip({
                anchor: 'left',
                target: cmp,
                html: '10',
                cls: 'fbNotification',
                autoRender: true,
                renderTo: Ext.getBody(),
                autoHide: false,
                shadow: false,
                padding: 0,
                width: 16,
                shrinkWrap: 0,
                anchorToTarget: true,
                mouseOffset: [-4, -8],
                listeners: {
                    beforehide: function () {
                        return false;
                    }
                }
            });

            tooTip.show();
        }
    </script>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />

        <ext:Panel ID="Panel1" runat="server" Title="Panel with toolbars" Width="600" Height="300">
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button ID="b1" runat="server" Icon="Add" StandOut="true" Text="Notifications">
                            <Listeners>
                                <Render Fn="createTooltp"></Render>
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarFill />
                        <ext:Button runat="server" EnableToggle="true" ToggleGroup="G1" Icon="GroupAdd" Pressed="true" />
                        <ext:Button runat="server" EnableToggle="true" ToggleGroup="G1" Icon="GroupDelete" />
                        <ext:Button runat="server" EnableToggle="true" ToggleGroup="G1" Icon="GroupEdit" />
                    </Items>
                </ext:Toolbar>
            </TopBar>
        </ext:Panel>
    </form>
</body>
</html>

关于c# - Facebook 喜欢 Ext3 按钮的通知图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14117407/

相关文章:

c# - MVVMLight 具有对应 View 的多个实例键控 View 模型

c# - 如何扩展 Entity Framework 6.1.3 生成的类?

c# - 无法获取GridView中Linkbutton的文本

android - 我的汉堡菜单的导航栏切换按钮在平板电脑上不显示

jquery - 动态生成的 <div> jQuery 切换行为问题

php - 如何使用 PHP 和 CSS nth-child 生成 ABBAABBA... 序列

C# 如何完全禁用用户按钮

c# - 如何从数据库绑定(bind) GridView

c# - 将我的 Web 应用程序从 .Net 3.5 升级到 .Net4.0 后,出现安全透明规则失败

javascript - 当我单击按钮 asp.net (angularjs) 时如何重新加载 ng-repeat