如何在浏览器中更改视口的百分比?

时间:2012-04-07 15:16:16

标签: extjs

我的视口适合所有浏览器,但我希望它只适合浏览器宽度的80%。我该怎么做? 这是我下面的代码,也许你想看到它。

这是我的视口代码:             var view = new Ext.Viewport({                 布局:'边界',                 autoScroll:true,                 边框:是的,                 项目:[标题,菜单                 {                     地区:'南',                     可折叠:错误,                     填充:'25 25 25 25',                     html:'

Sanguis Team 2012

',                     边框:是的,                     身高:100                 },内容                 ]             });

Ext.onReady(function(){
//var topHTML = '<img style="margin-left: 5px" src="Google_maps_logo.png" alt="logo" height="60" width="380">';
//Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';


            Ext.QuickTips.init();


            var item1 = new Ext.Panel({
                title: 'Kan Bağışı',
                collapsible :   true,
                collapsed: true,
                padding: '5 5 5 5' ,
                html: '<a href="#">Nerede Kan verebilirim?</a><br/>' +
                      '<a href="#">Kan Bağışlama Süreci</a>'
            });

            var item2 = new Ext.Panel({
                title: 'Kan Hakkında',
                collapsed: true,
                padding: '5 5 5 5' ,
                collapsible :   true,
                html: '<a href="#">Kanın Yapısı ve Görevleri Nelerdir?</a><br/>' +
                      '<a href="#">Kan Bağışlarım Nerede kullanılıyor</a><br/>'+
                      '<a href="#">Kan Grupları Hakkında Bilgiler</a><br/>'+
                      '<a href="#">Kana Yapılan Testler</a><br/>'+
                      '<a href="#">Dünya ve Türkiyede Kan Bağışı</a>'
            });

            var item3 = new Ext.Panel({
                title: '<a style="color: #FFFFFF;" href="#">Sıkça Sorulan Sorular</a>',
                collapsible :false,
                titleCollapse: false

            });



            var item4 = new Ext.Panel({
                title: 'Site Kullanımı',
                collapsed: true,
                padding: '5 5 5 5' ,
                collapsible :   true,
                html: '<a href="#">Site Nasıl Çalışmaktadır</a><br/>' +
                      '<a href="#">Kan İsteğinde Nasıl Bulunabilirim?</a><br/>'
            });

            var item5 = new Ext.Panel({
                padding: '5 5 5 5' ,
                title: 'Kullanıcı Girişi',
                bodyStyle   :   'padding : 10px',
                layout      :   'form',

                items:  [
                {
                    xtype:  'field',
                    fieldLabel: 'E-posta',
                    width:  100
                },{
                    xtype:  'field',
                    fieldLabel: 'Şifre',
                    inputType:'password',
                    width:  100
                },
                {
                    xtype:  'button',
                    text:   'Giriş',
                    style: {
                    marginLeft: '170px'
                    },
                    align:  'right',
                    handler     :   function(btn){
                    Ext.MessageBox.alert('','kontrol yapılacak!!');
                    }
                },
                {
                    border  : false,
                    html:'<a href="#">Şifremi Unuttum</a>'
                }
                ]
            });

            var item6 =new Ext.Panel({
                border: false,
                html: '<a href="kayit.html"><img src="../images/kaydol.jpg" /></a>'
            });



        var menuBar = new Ext.Panel({
            //layout: 'accordion',
            autoScroll: true,
            defaults: {autoScroll: true},
            region: 'west',
            width: 310,
            defaults: {
                hideCollapseTool : false,
                //border: true
            },
            layoutConfig: {
//              titleCollapse: false,
                animate: true,
//              activeOnTop: true,
                autoScroll: true

            },

            margins:'5 0 5 5',
            split:false,
            items: [item1, item2, item4, item3, item5,item6]
        });


        var content = new Ext.Panel({
            region: 'center',
            autoScroll: true,
            margins:'5 5 5 0',
            layoutConfig : {
                align : 'stretch'
            },
            html:'Ajax content will come here'
        });

        var header=new Ext.Panel({
            renderTo: document.body,
            layout: 'fit',
            region: 'north',
            html: '<p align="center"><img src="../images/banner.jpg" align="middle"/></p>',
            height:150,
            tbar: [
            {
                text: '<b>Ana Sayfa</b>',
                iconCls: 'bmenu',  
                handler: function(){ alert('blah'); }
            },
            {
                text: '<b>Hakkımızda</b>',
                iconCls: 'bmenu', 
                handler: function(){ alert('blah'); }
            },
            {
                text: '<b>Duyurular</b>',
                iconCls: 'bmenu', 
                handler: function(){ 
            }
            },
            {
                text: '<b>İletişim</b>',
                iconCls: 'bmenu',  // <-- icon
                handler: function(){ alert('blah'); }
            }]
        });

        var view = new Ext.Viewport({
            layout: 'border',
            autoScroll: true,
            border: true,
            items:[header,menuBar
            ,{
                region: 'south',
                collapsible: false,
                padding: '25 25 25 25' ,
                html:'<br/><br/><p align="center"><b>Sanguis Team 2012</b></p>',
                border: true,
                height: 100
            },content
            ]
        });

        /*var templates = new Ext.Window({
            width:900,
            height:700,
            id:'Templates',
            resizable:false,
            //layout:'border',
            //border:true,
            closable:false,
            title:'Plantillas',
            items:view
        });

        templates.show();*/




//      view.render('anasayfa');
}); 

1 个答案:

答案 0 :(得分:1)

视口上没有maxwidth属性,因为视口始终是窗口的大小。

这有效:

  1. 使用视口,将其布局设置为锚点
  2. 向视口添加容器
  3. 将其锚属性设置为'80%100%'
  4. 在容器内放入任何你想要的东西。如果需要,可以给出容器边框布局