可自定义的主页

原文:Customizable Home Pages   翻译:YuL

最近这些天好象每个主流的站点都有了可自定义的“我的”主页(my.yahoo.com, my.msn.com, my.ebay.com……)。其实一旦你能从基于表格的网页设计思想里走出来,那这实现起来并不难。(原文有个例子,这里省略)

你可能会花费一整天的时间来尝试建立表格布局,但是左边还是很杂乱而且难以更新。或者你可以使用div标签和大概一半的HTML代码,并且用CSS来处理所有的设计块。

None.gif < div  class ="main" >
None.gif    
< div  class ="left" >
None.gif        
< div  class ="leftSubheadDark"  runat ="server"  id ="hdStocks" > Stocks </ div >
None.gif        
< div  class ="leftSubDark"  runat ="server"  id ="Stocks" >
None.gif            DJIA 10087.51 -191.24
None.gif            
< br >
None.gif            NASDAQ 1908.15 -38.56
None.gif            
< br >
None.gif            YHOO 32.46 -1.00
None.gif            
< br >
None.gif            
< asp:LinkButton  Runat ="server"  ID ="HideStocks" > Hide </ asp:LinkButton >
None.gif        
</ div >
None.gif        
< div  class ="leftSubheadLight"  runat ="server"  id ="hdDates" > Events </ div >
None.gif        
< div  class ="leftSubLight"  runat ="server"  id ="Dates" >< b > July 4: </ b >  Independence Day
None.gif            
< br >
None.gif            
< b > December 25: </ b >  Christmas < br >
None.gif            
< b > January 1: </ b >  New Years Day < br >
None.gif            
< asp:LinkButton  Runat ="server"  ID ="hideDates" > Hide </ asp:LinkButton ></ div >
None.gif        
< div  class ="leftSubheadDark"  runat ="server"  id ="hdWeather" > Weather </ div >
None.gif        
< div  class ="leftSubDark"  runat ="server"  id ="Weather" > Lincoln, NE : 53/72 F
None.gif            
< br >
None.gif            
< asp:LinkButton  Runat ="server"  ID ="hideWeather" > Hide </ asp:LinkButton ></ div >
None.gif    
</ div >
None.gif    
< div  class ="right" >
None.gif        
< div  class ="rightSubheadYellow"  runat ="server"  id ="hdTopStories" > Top Stories </ div >
None.gif        
< div  class ="rightSubYellow"  runat ="server"  id ="TopStories" > The Sky Is Fallingdot.gif < br >
None.gif            Governer Alberts Re-Elected to 22nd termdot.gif
< br >
None.gif            Scientist Predict Next Earthquakedot.gif
< br >
None.gif            
< asp:LinkButton  Runat ="server"  ID ="hideTopStories" > Hide </ asp:LinkButton ></ div >
None.gif        
< div  class ="rightSubheadYellow"  runat ="server"  id ="hdWord" > Word of the Day </ div >
None.gif        
< div  class ="rightSubYellow"  runat ="server"  id ="Word" >< b > hero </ b >< br >
None.gif            n. pl. he·roes
< br >
None.gif            
< br >
None.gif            1. In mythology and legend, a man, often of divine ancestry, who is endowed 
None.gif            with great courage and strength, celebrated for his bold exploits, and favored 
None.gif            by the gods.
< br >
None.gif            2. A person noted for feats of courage or nobility of purpose, especially one 
None.gif            who has risked or sacrificed his or her life: soldiers and nurses who were 
None.gif            heroes in an unpopular war.
None.gif            
< br >
None.gif            
< asp:LinkButton  Runat ="server"  ID ="hideWord" > Hide </ asp:LinkButton >
None.gif        
</ div >
None.gif    
</ div >
None.gif
</ div >
None.gif <style>
ExpandedBlockStart.gifContractedBlock.gifdiv.main
{dot.gif} {
InBlock.gifwidth
:820px;
ExpandedBlockEnd.gif
}
        
None.gif        
ExpandedBlockStart.gifContractedBlock.gifdiv.left
{dot.gif} {
InBlock.gifwidth 
:200px;
InBlock.giffloat
:left;
ExpandedBlockEnd.gifbackground-color
:#ffffff;}

None.gif
ExpandedBlockStart.gifContractedBlock.gifdiv.leftSubDark
{dot.gif} {
InBlock.gifmargin
:0px 1px 0px 1px;
InBlock.gifborder
: 1px solid #0049A5;
InBlock.gifpadding
: 4px 4px 4px 4px;
InBlock.giffont-family
: arial, sans-serif;
InBlock.giffont-size
:10pt;
ExpandedBlockEnd.gif
}

ExpandedBlockStart.gifContractedBlock.gifdiv.leftSubheadDark
{dot.gif} {
InBlock.gifbackground-color
:#0049A5;
InBlock.gifcolor
:#ffffff;
InBlock.gifpadding
: 0px 0px 0px 4px;
InBlock.gifmargin
:2px 1px 0px 1px;
InBlock.giffont-family
: arial, sans-serif;
InBlock.giffont-weight
:bold;
ExpandedBlockEnd.giffont-size
:10pt;}

None.gif
ExpandedBlockStart.gifContractedBlock.gifdiv.right
{dot.gif} { 
InBlock.gifwidth 
:600px;
InBlock.giffloat
:left;
InBlock.gifmargin
:0px 0px 0px 0px;
ExpandedBlockEnd.gifbackground-color
:#ffffff }

None.gif
ExpandedBlockStart.gifContractedBlock.gifdiv.rightSubheadYellow
{dot.gif} {
InBlock.gifbackground-color
:#ffcf00 ;
InBlock.gifcolor
:#black;
InBlock.gifmargin
:2px 1px 0px 1px;
InBlock.gifpadding
: 6px 6px 6px 6px;
InBlock.giffont-family
: arial, sans-serif;
InBlock.giffont-weight
:bold;
InBlock.giffont-size
:10pt;
ExpandedBlockEnd.gif
}

None.gif
ExpandedBlockStart.gifContractedBlock.gifdiv.rightSubYellow
{dot.gif} {
InBlock.gifmargin
:0px 1px 0px 1px;
InBlock.gifborder
: 1px solid #ffcf00;
InBlock.gifpadding
: 4px 4px 4px 4px;
InBlock.giffont-family
: arial, sans-serif;
InBlock.giffont-size
:10pt;
ExpandedBlockEnd.gif
}

None.gif</style>

现在你自己的选项都整洁地包含在div标签里了,当你点链接按钮时便可以隐藏它们了:
ExpandedBlockStart.gif ContractedBlock.gif      Private   Sub Page_Load() Sub Page_Load(ByVal sender As System.Object, _
InBlock.gif    
ByVal e As System.EventArgs) Handles MyBase.Load
InBlock.gif        
'Put user code to initialize the page here
InBlock.gif

ExpandedBlockEnd.gif    
End Sub

None.gif
ExpandedBlockStart.gifContractedBlock.gif    
Private   Sub HideStocks_Click() Sub HideStocks_Click(ByVal sender As System.Object, _
InBlock.gif    
ByVal e As System.EventArgs) Handles HideStocks.Click
InBlock.gif        hdStocks.Visible 
= False
InBlock.gif        Stocks.Visible 
= False
ExpandedBlockEnd.gif    
End Sub

None.gif
ExpandedBlockStart.gifContractedBlock.gif    
Private   Sub hideDates_Click() Sub hideDates_Click(ByVal sender As System.Object, _
InBlock.gif    
ByVal e As System.EventArgs) Handles hideDates.Click
InBlock.gif        hdDates.Visible 
= False
InBlock.gif        Dates.Visible 
= False
ExpandedBlockEnd.gif    
End Sub

None.gif
ExpandedBlockStart.gifContractedBlock.gif    
Private   Sub hideWeather_Click() Sub hideWeather_Click(ByVal sender As System.Object, _
InBlock.gif    
ByVal e As System.EventArgs) Handles hideWeather.Click
InBlock.gif        hdWeather.Visible 
= False
InBlock.gif        Weather.Visible 
= False
ExpandedBlockEnd.gif    
End Sub

None.gif
ExpandedBlockStart.gifContractedBlock.gif    
Private   Sub hideTopStories_Click() Sub hideTopStories_Click(ByVal sender As System.Object, _
InBlock.gif    
ByVal e As System.EventArgs) Handles hideTopStories.Click
InBlock.gif        hdTopStories.Visible 
= False
InBlock.gif        TopStories.Visible 
= False
ExpandedBlockEnd.gif    
End Sub

None.gif
ExpandedBlockStart.gifContractedBlock.gif    
Private   Sub hideWord_Click() Sub hideWord_Click(ByVal sender As System.Object, _
InBlock.gif    
ByVal e As System.EventArgs) Handles hideWord.Click
InBlock.gif        hdWord.Visible 
= False
InBlock.gif        Word.Visible 
= False
ExpandedBlockEnd.gif    
End Sub

在现实应用中可能包含一个注册/登录系统和存储用户选择参数的数据库。你能够通过page_load事件读取这些参数并且隐藏选项;显然你还想实现一个二级页面,在那个页面中用户可以选择他希望显示的选项。你可能还想简单地在每个盒子(box)里融合javascript和其它链接来“最小化”盒子。这个代码可能与左侧导航菜单的脚本很相似。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值