仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 848|回复: 8
打印 上一主题 下一主题

[DIV+CSS] 给大家带来CSS网页计划技能十则

[复制链接]
爱飞 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 00:12:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
在几乎所有的浏览器上都可以使用。15.以前一些非得通过图片转换实现的功能,现在只要用CSS就可以轻松实现,从而更快地下载页面。
WEBJX.COM:不要说你看不懂,只是你不肯意看。:)

  IthoughtIdsharesomeofmyhabitswhenitcomestodoingCSSworkandletmewarnyou,someofwhatIhavetosayisprobablyalittlecontroversial.Butwhatslifewithoutlivingitontheedge.(Yeah,IliveanexcitinglifewhenCSSisconsideredtheedge.)

pxforfontsizes-用px作为字体巨细的单元

  Sacrilege,Iknow.ThereareperfectlygoodwaystogetconsistentfontsizingandIreallyshouldusethembutInternetExploreristheonlybrowserthatIcanthinkofthatdoesntresizetext.IfthemajorityofyouraudienceusesIE,thenbenicetothemanddontusepixels.Otherwise,IfigurewithIE7supportingit,pixelsarethenewems.

  Whenusingpixelsizes,Ialsogettobesparinginmyusage.Ispecifyitonthebodyandanyheadersthatneedit.Inheritanceislessofanissue(howmanysiteshaveyouseenlistitemsinexplicablysmallerthantherestofthecontentlikeitwaslessimportant).

CSSdeclarationsononeline-CSS声明写在一行

  Ivealwaysputmyentiredeclarationononeline.HeresanexampletoexplainwhatImean:

h2{font-size:18px;border:1pxsolidblue;color:#000;background-color:#FFF;}

h2{
font-size:18px;
border:1pxsolidblue;
color:#000;
background-color:#FFF; /*www.poluoluo.com*/
}
  Thesecondonemaylookprettierbutitsuredoesnthelpmefindanything.Whenlookingforsomethinginastylesheet,themostimportantthingistheruleset(thatsthepartbeforethe{and}).Imlookingforanelement,anidoraclass.Havingeverythingononelinemakesscanningthedocumentmuchquickerasyousimplyseemoreonapage.OnceIvefoundtherulesetIwaslookingfor,findthepropertyIwantisusuallystraightforwardenoughastherearerarelythatmany.

BlockingtheStyles-代码分块

  Ibreakdownmystylesheetintothreeseparateblocks.Thefirstisstraightelementdeclarations.Changethebody,somelinksstyles,someheaderstyles,resetmarginsandpaddingonforms,andsoon.ThisisusuallyasmallblockasIonlyliketoredefinewhatIneedto.Noglobalmarginandpaddingresetforme.Iclearthebodyandformandmaybeadjustparagraphifthedesignreallyneedsit.Otherwise,letthebrowserhandleit.Ifindthemoreyoutrytooverridewhatthebrowserdoes,themorestylesyouhavetoputin,whichsimplyaddstothetimetotrackdownbugsandmaintainthecode.

  Afterelementdeclarations,Ihavemyclassdeclarations;thingslikeclassesforanerrormessageoracalloutwouldgohear.Iusuallyonlyhaveacoupleofthese.

  Finally,themeat.Istartbydeclaringmymaincontainersandthenanystylesforelementswithinthosecontainersareindented.Ataquickglance,Icanseehowmypageisbrokendownandmakesiteasiertoknowwheretolookforthings.Illalsodeclarecontainerseveniftheydonthaveanyrules.

#content{float:left;}
#contentp{...}

#sidebar{float:left;}
#sidebarp{...}

#footer{clear:both;}
#sidebarp{...} /*www.poluoluo.com*/
BrowserSupport-扫瞄器兼容

  Supportonlythelatestbrowsers.ThatmeansdroppingsupportforIE5andIE5.5.Lotsoftimeandefforttobesavedhere.NoboxmodelhacksneededforIE6.Infact,insupportingjustthemostrecentversionsofbrowsers,Iendupusingveryfewhacks.AlongwithusingveryfewhacksmeansIcanavoidshovellingdifferentstylesheetstoseparatebrowsers.Ihaveonesheet,andthatsit.AnyhacksIdousearenormallycommentedassuch.Similartotheuseofpixelmeasurements,youhavetoconsideryouraudiencebeforedroppingbrowsersupport.

  ThebiggestthingformeisstilltriggeringhasLayoutinIEtodofloatcontainmentandIvebeenusingzoom:1forthat.Ilikeitbecauseitsinnocuousandshouldntmesswithanythingelse.

ContainingFloats-“包括”式浮动

  Ijusttouchedonfloatcontainmentsoletsexpandonthat.Mycurrentapproachtocontainingfloatsisusingoverflow:hidden(withpossiblyzoom:1forInternetExplorer).Noclearingdivoruseof:after.Onlyworryaboutcontainingyourfloatsifyouhaveabackgroundyouaretryingtosetonyourcontainer.Theoverflowshouldbesetonthecontainer.

  Keepinmindthatthecontentwithinthecontainershouldbedesignedtostaywithinthecontainer.Anythingtoobiganditllgetclipped.Shiftingthingsusingnegativemarginsoutsidethecontainerwillalsogetclipped.

UnderstandOverflow-了解与利用溢出

  OverflowisusuallywherepeoplegetbitbyIE.Ifyouvegottwofloatedelementsandthecontentfromtheleftcontaineroverflowsthen,inIE,thecontainergrowsandinevitablypushestherightcontainerbelowit.Thisisusuallyasignthatyouvemessedupyourmargins,widths,orpaddingononeofthesecontainersbutFirefox(etal)wontrevealthis.Usingsomethinglikeoverflow:hiddenoroverflow:scrollonacontainercanhelppreventIEfromallowingthecontenttopushthewidthofthecontainerbutyourebetterofftryingtofixtheissueinthedesign.

AllowBlockElementstoFillTheirSpaceNaturally-同意块元素的空缺

  Myruleofthumbis,ifIsetawidth,Idontsetmarginorpadding.Likewise,ifImsettingamarginorpadding,Idontsetawidth.Dealingwiththeboxmodelcanbesuchapain,especiallyifyouredealingwithpercentages.Therefore,Isetthewidthonthecontainersandthensetmarginandpaddingontheelementswithinthem.Everythingusuallyturnsoutswimmingly.

UseCSSShorthand-利用CSS属性缩写

  ThismightseemlikebeatingadeadhorsebutIstillseepeopledoingreallyverbosestatementswheretheyresettingmargin-top,margin-right,margin-bottomandmargin-left.Mygeneralruleofthumbis,youcanusethelongformonlyifyouresettingoneside.Onceyouhavetosetmorethanoneside,itlltakelessbytestouseshorthand.

  Inshorthand,rememberthatthepropertiesstartatthetopandworkclockwise.margin:toprightbottomleft;Itsalsohandytoknowtheshorterformsifyouhaveequalvaluesfortopandbottomorleftandright.

margin:5px10px20px;/*topleft/rightbottom_www.poluoluo.com*/
margin:10px20px;/*top/bottomleft/right*/
margin:0;/*allsides*/
  Forborder,ifyouonlyhavetosetmorethanonesidedifferentlythenusetwodeclarations.Thefirsttosetallsides,andthenasecondtochangethevaluesforoneoftheproperties.

/*1pxblueborderontheleftandbottom_www.poluoluo.com*/
border:1pxsolidblue;border-width:001px1px;
AvoidUnnecessarySelectors-制止过剩的选择器
  Justspecifytheminimumnumberofselectorsnecessaryforthestyle.Ifyoufindyourselfdoingulli{...}ortabletrtd{...}thenyourebeingmoreverbosethanyouneed.LIswillinevitablybeinULs(okay,IsupposetheycouldfindthemselvesinOLs,inwhichcase,bemorespecificforthosestyles)andaTDwillinevitablybeinaTRandaTABLE.

  OrputtingtheelementnameinfrontofanIDselector(Example:div#navigation).Iusedtodothisbecauseitdhelpme"remember"whichelementtheIDison.Asitturnsout,Itendtousesimilarclassnamesfromprojecttoprojectandtheyinevitablyappearonthesameelements.Ialsotendtojustdoasearchtofindwheresomethingis.So,thesedays,Ijustleaveitat#navigation.

  Usinglessselectorswillmeanlessselectorswillbeneededtooverrideanyparticularstyle—thatmeansitseasiertotroubleshoot.

KeepitSimple-坚持简便

  Ifithasntbeenevidentthroughoutthispost,onlyaddwhenyouneedto,andthatincludeshacks.Noneedtogetanymorecomplicatedthanyouneedto.

  Now,Idlovetohearsomeofyourtips.
你用什么用的熟练就用什么,讲究的是效率,客户永远不管你用什么,页面就要好看,功能就要好用,还有时间和成本的问题。
爱飞 该用户已被删除
沙发
 楼主| 发表于 2015-1-18 05:31:53 | 只看该作者
以上大概就是文字图片的一些链接方法,通过学习Dreamweaver、练习让我对dreameaver8有了进一步的认识,他其实是一款很好的建立Web站点和应用程序的软件。它将可视布局工具、应用程序开发功能和代码编辑支持组合在一起,其功能强大,使得各个层次的开发人员和设计人员都能够快速创建界面吸引人的基于标准的网站和应用程序。
金色的骷髅 该用户已被删除
板凳
发表于 2015-1-25 21:31:48 | 只看该作者
滚动条)层属性--溢出(visible/hidden/scroll/auto)
深爱那片海 该用户已被删除
地板
发表于 2015-2-4 07:09:54 | 只看该作者
帧(frames)和表格的制作速度快的令您无法想像。进阶表格编辑功能使您简单的选择单格、行、栏或作未连续之选取。
飘灵儿 该用户已被删除
5#
发表于 2015-2-9 18:40:36 | 只看该作者
在刚开始接触网页的第一堂课上,听说网页制作会是一门很无聊并且很难听懂的过程,而事实却印证了这样一个事实。
柔情似水 该用户已被删除
6#
发表于 2015-2-27 17:35:21 | 只看该作者
是当我和赵丽芬崔明艳老师进行交流后,很快就了解了还不太清楚的内容和并不了解的知识(像布局表格、绘制布局单元格等)。
小魔女 该用户已被删除
7#
发表于 2015-3-9 11:49:24 | 只看该作者
HTML技术的不断发展和完善,随之而产生了众多网页编辑器,从网页编辑器基本性质可以分为所见即所得网页编辑器和非所见即所得网页编辑器(则原始代码编辑器)
莫相离 该用户已被删除
8#
发表于 2015-3-17 00:07:54 | 只看该作者
所见则所得网页编辑器的优点就是直观性,使用方便,容易上手.
第二个灵魂 该用户已被删除
9#
发表于 2015-3-23 09:24:39 | 只看该作者
还可以在Dreamweaver常用工具中选择超级链接,完成相应的填写即可。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-22 20:02

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表