6.5 Ext.util.CSS 更好地操作css_html/css_WEB-ITnose

php中文网
发布: 2016-06-21 08:50:07
原创
1562人浏览过

<div class="box">        <div class="w_320" id="myPanel"></div>        <div class="w_320" id="myPanel1"></div></div>
登录后复制
.box { padding:50px 0 0 50px; }* { padding:0; margin:0; }.w_320 { width:320px; float:left; margin-right:15px;margin-bottom:15px; }.my-foo-trigger { border-radius:5px; }
登录后复制
Ext.onReady(function(){        //6.5 Ext.util.CSS 更好地操作css        //6.5.1 createStyleSheet(String cssText,String id) 自动创建一个样式表供html使用    //cssText : .myClass(color:blue;)  id : 将指定创建的css绑定到一个id        //6.5.2 getRule() 通过指定的css名称查询css规则        var myPanel = new Ext.Panel({        title : '样式表的创建和获取',        width : 320,        height : 210,        renderTo : 'myPanel',        frame : true,        html : '<div class="myClass" style="height:160px;padding:5px">我是内容部分</div>',        buttons : [{                text : '添加样式',                handler : addSs            },{                text : '移除样式',                handler : reSs            }        ]    });    //创建    Ext.util.CSS.createStyleSheet(".myClass{color:blue}","the");    //获取样式规则    var cssObj = Ext.util.CSS.getRule(".myClass",true);    console.info("颜色:"+cssObj.style.color);        //6.5.3 swapStyleSheet() 动态改变页面的风格    var themes = [        {'theme':'gray风格','css':'theme-gray/resources/theme-gray-all.css'},        {'theme':'classic风格','css':'theme-classic/resources/theme-classic-all.css'},        {'theme':'crisp风格','css':'theme-crisp/resources/theme-crisp-all.css'},        {'theme':'triton风格','css':'theme-triton/resources/theme-triton-all.css'},        {'theme':'neptune风格','css':'theme-neptune/resources/theme-neptune-all.css'},        {'theme':'aria风格','css':'theme-aria/resources/theme-aria-all.css'}    ];    //创建主体数据模型    Ext.define('Theme',{        extend: 'Ext.data.Model',        fields : ['theme','css']    });    //创建主体数据源    var themeStore = Ext.create('Ext.data.Store',{        model : 'Theme',        data : themes    });    var themeChange = Ext.create('Ext.form.ComboBox',{        id : 'themeChange',        width : 180,        labelWidth : 60,        labelSeparator : ': ',        fieldLabel : '样式选择',        store : themeStore,//数据源        editable : false,        triggerAction : 'all',//单击触发会显示全部数据        displayField : 'theme',        valueField : 'css',        queryMode : 'local',//本地模式        value : 'theme-gray/resources/theme-gray-all.css',//默认风格        listeners : {            'collapse' : function(){                Ext.util.CSS.swapStyleSheet('theme','plugin/ext-6.0.0/build/classic/'+this.getValue());            }        }    });    //定义panel    Ext.create('Ext.form.FormPanel',{        title : 'Ext.form.ComboBox本地数据源示例',        renderTo : 'myPanel1',        bodyStyle : "padding:5px;",        frame : true,        height : 210,        width : 320,        defaults : {            labelSeparator : ': ',            labelWidth : 70,            width : 200,            labelAlign : 'left'        },        items : themeChange    });        //6.5.4    removeStyleSheet() 移除样式规则    //创建样式规则    function addSs(){        Ext.util.CSS.createStyleSheet(".myClass{color:blue}","the");    }    //移除样式规则    function reSs(){        Ext.util.CSS.removeStyleSheet("the");    }    });
登录后复制


Giiso写作机器人
Giiso写作机器人

Giiso写作机器人,让写作更简单

Giiso写作机器人 56
查看详情 Giiso写作机器人
HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号