Tiny快速入门之Web界面快速开发实践

简介:
本来想改改OSChina的界面,但是研究了一下,OSChina界面实在是高大上呀,不是做不出来,只是工作量比较大,因此还是做个简单的网站来展示一下用Tiny开发界面的过程,同时在展示过程的同时,会把相关的知识做一个充分的介绍 

一、寻找网站模板

要做网站,不能没有模板,自己不会做网页设计,咋办?问谷歌找百度呗,找了一阵,看到下面这个模板不错,就它了。

http://www.tooplate.com/zip_files/2042_the_block.zip

相仔细了解这篇文章的同学,建议把原板的下载下来,对比着看,会更有感觉。

二、开工制作 

1.编写default.layout布局文件

位置:/default.layout

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
     < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
     < title >演示网站-${pageTitle}</ title >
     < meta name = "keywords" content = "" />
     < meta name = "description" content = "" />
     < script src = "${TINY_CONTEXT_PATH}/uiengine.uijs" ></ script >
     < link href = "${TINY_CONTEXT_PATH}/uiengine.uicss" rel = "stylesheet" />
</ head >
< body >
     ${pageContent}
</ body >
</ html >
这个是标准布局了,直接贴过来,唯一要改的就是标题处加了“演示网站-”开头。   
里面引入的js和css是TinyUI引擎所独有的,主要处理JS,CSS顺序处理、合并、打包等相关,由于这个是框架内部实现的部分,这里只是使用就不展开来叙述了。

${pageContent} 这个标记了渲染替换的位置,一个layout文档中必须有且只能有一个(如果没有,你会发现不管怎么写页面,内容都是布局的内容;如果有多个,你会发现页面中的内容会加多次)。

2.编写UI组件定义文件

位置:/demosite.ui.xml

?
1
2
3
4
5
6
< ui-components >
     < ui-component name = "demosite" dependencies = "" >
         < css-resource >/css/jquery.lightbox-0.5.css,/css/slider_style.css,/css/tooplate_style.css</ css-resource >
         < js-resource >/js/jquery.js,/js/jquery.lightbox-0.5.js,/js/swfobject.js</ js-resource >
     </ ui-component >
</ ui-components >
这里主要是定义用到的js和css,由于只是一个网站,就简单处理,只写一个了,实际应用当中,要根据用途和职能不同定义为许多个UI组件包。

3.编写通用宏定义

位置:/common.component

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#macro a(title url)
< a href = "#link(url)" >${title}</ a >
#end
 
#macro img(url alt)
< img src=#link(url) alt = "${alt}" >
#end
 
#macro link(url)#if(url.startsWith("/"))${TINY_CONTEXT_PATH}#end${url}#end
 
#macro pageTitle(title page)
     #!set(pageTitle=title)
     #!set(activePage=page)
#end
这面主要定义了4个宏,a是超连接的,img是图片的,link是把链接地址转换成绝对地址,pageTitle用于定义页面的标题和当前页是哪个页面的。

4.编写业务宏

位置:/demosite.component

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#macro header()
< div id = "tooplate_header" >
     #bodyContent
</ div >
#end
 
#macro siteTitle(title))
< div id = "site_title" >< h1 >< a href = "#" >${title}</ a ></ h1 ></ div >
#end
 
#macro menu()
< div id = "tooplate_menu" >
     < ul >
         #bodyContent
     </ ul >
</ div >
#end
 
#macro menuItem(url title page)
< li >< a href = "#link(url)" #if(activePage==page) class = "current" #end >${title}</ a ></ li >
#end
 
#macro tooplateWrapper())
< div id = "tooplate_wrapper" >
     #bodyContent
</ div >
#end
 
#macro tooplateMiddleSub()
< div id = "tooplate_middle_sub" >
     #bodyContent
</ div >
#end
 
#macro tooplateMiddle()
< div id = "tooplate_middle" >
     #bodyContent
</ div >
#end
 
 
#macro flashGridSlider()
< div id = "flash_grid_slider" >
     < a rel = "nofollow" href = "http://www.adobe.com/go/getflashplayer" >
         < img src = "http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
              alt = "Get Adobe Flash player" />
     </ a >
</ div >
< script type = "text/javascript" >
     var flashvars = {};
     flashvars.xml_file = '#link("/photo_list.pagelet")';
     var params = {};
     params.wmode = "transparent";
     var attributes = {};
     attributes.id = "slider";
     swfobject.embedSWF('#link(
         "/flash_slider.swf")', "flash_grid_slider", "780", "210", "9.0.0", false, flashvars, params, attributes);
</ script >
#end
 
#macro tooplateContent())
< div id = "tooplate_content" >
     < span class = "content_top" ></ span >
     #bodyContent
     < div class = "cleaner" ></ div >
</ div >
#end
 
#macro tooplateFooter())
< div id = "tooplate_footer" >
     #bodyContent
     < div class = "cleaner" ></ div >
</ div >
#end
 
#macro box220(class)
< div class = "box_w220 ${class}" >
    #bodyContent
</ div >
#end
 
#macro box330(class)
< div class = "box_w330 ${class}" >
     #bodyContent
</ div >
#end
 
#macro gallery()
< div id = "gallery" >
     #bodyContent
</ div >
#end
 
#macro galleryBox(largeImage smallImage title alt info class)
< div class = "gallery_box ${class}" >
     < div class = "gallery_img" >< span ></ span >
         < a href = "#link(largeImage)" title = "${title}" >
             < img src = "#link(smallImage)" alt = "${alt}" />
         </ a >
     </ div >
     < h6 >${info}</ h6 >
</ div >
#end
 
#macro postBos(comment title imageUrl imageAlt postedInList commentCount)
< div class = "post_box" >
     < div class = "comment" >< a href = "#" >${comment}</ a ></ div >
     < h2 >${title}</ h2 >
 
     < div class = "image_wrapper image_fl" >< span ></ span >#img(imageUrl imageAlt)</ div >
     < p >< span class = "cat" >Posted in
      #for(postedIn in postedInList)
         < a href = "#" >${postedIn}</ a >&nbsp;
      #end
     </ span ></ p >
     #bodyContent
     ${commentCount} comments < a class = "more float_r" href = "#" >More</ a >
     < div class = "cleaner" ></ div >
</ div >
#end



业务宏的定义,就是根据情况从美工制作的页面文件中抽取一些具有共性的内容,定义成一个宏,这样以后使用的时候,就只要使用有意义的宏而不是原来一堆一堆的Html标记。

5.定义演示网站布局文件

分析一下几个页面,都有页头,页脚,菜单,因此可以把这些共性的文件放在演示网站布局文件中: 

位置:/page/default.layout

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#@tooplateWrapper()
     #@header()
         #siteTitle("The Block")
         #@menu()
             #menuItem("index.page" "Home" "Home")
             #menuItem("about.page" "About Us" "About")
             #menuItem("blog.page" "Blog" "Blog")
             #menuItem("gallery.page" "Gallery" "Gallery")
             #menuItem("contact.page" "Contact" "Contact")
         #end
     #end
 
     ${pageContent}
 
     #@tooplateFooter()
     Copyright © 2048 < a href = "#" >Company Name</ a > - Design: < a href = "http://www.tooplate.com" >tooplate</ a >
 
     #end
 
#end
< script type = "text/javascript" >
     $('#gallery a').lightBox();
</ script >
< script type = "text/javascript" >
     $('#map a').lightBox();
</ script >
上面代码的函义是:

在整个页面中,上面放置Header,下面旋转Footer,中间放置内容

最后两段js,是说:对某指定选择器中的图片用lightbox去进行处理。

这里就把所有的通用的部分都抽取到布局文件中了。

6.定义相关页面

首页:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pageTitle("Home" "Home")
 
#@tooplateMiddle()
   #flashGridSlider()
#end
 
#@tooplateContent()
 
     < h2 >Welcome To The Block!</ h2 >
 
     < div class = "image_wrapper image_fl" >< span ></ span >
         #img("/images/tooplate_image_01.jpg" "image")
     </ div >
     < p >< em >The Block is a < a rel = "nofollow" href = "http://www.tooplate.com" >free website template</ a > from < a
             rel = "nofollow" href = "http://www.tooplate.com" >Tooplate</ a >. Credit goes to < a rel = "nofollow"
                                                                                           href = "http://www.photovaco.com" >Free
         Photos</ a > for photos used in this template.</ em ></ p >
 
     < p align = "justify" >Aliquam et augue et odio luctus posuere sit amet et nisi. Maecenas convallis, est sit amet
         convallis consectetur, elementum lacus, ut fermentum elit sem. Duis eu elit tortor, sed condimentum nulla.
         Phasellus varius posuere adipiscing. Mauris sodales dictum ullamcorper. Validate < a
                 href = "http://validator.w3.org/check?uri=referer" rel = "nofollow" >< strong >XHTML</ strong ></ a > and < a
                 href = "http://jigsaw.w3.org/css-validator/check/referer" rel = "nofollow" >< strong >CSS</ strong ></ a >.</ p >
 
     < div class = "cleaner h40" ></ div >
     #@box220()
         < h4 >pharetra id turpis< span >Lorem Ipsum Dolor</ span ></ h4 >
 
         < p > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porta adi Piscing libero, eget elem
             ntum lectus varius sed.</ p >
         < a href = "#" class = "more" >more</ a >
     #end
     #@box220()
         < h4 >semper nisl ac nibh< span >Donec Tincidunt Varius</ span ></ h4 >
 
         < p >Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
             eu mauris id neque porttitor.</ p >
         < a href = "#" class = "more" >more</ a >
     #end
     #@box220("rmb")
         < h4 >consect adipiscing elit< span >Etiam Gravida Sagittis</ span ></ h4 >
 
         < p >Cras eu egestas sem. Aenean mollis feugiat massa, eget pharetra nunc interdum non. Etiam euismod sem ac
             sem tincidunt adipiscin.</ p >
         < a href = "#" class = "more" >more</ a >
     #end
#end
由于这个里面的数据是具体写的,因此就没有再进行抽象,如果这些数据是从数据库来的,那可以再进行一下抽象,就可以用for循环直接搞定了。

关于:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pageTitle("About" "About")
 
 
#@tooplateMiddleSub()
     < h2 >About Our Company</ h2 >
     < p >Sed tempus nunc dolor, sit amet aliquet ligula. Ut euismod lectus vel ligula euismod id porttitor tortor placerat. Aenean tincidunt magna sit amet turpis auctor sagittis. Phasellus aliquet augue nec elit lacinia et faucibus massa scelerisque.</ p >
#end
 
#@tooplateContent()
     < h2 >Our Company Objectives</ h2 >
< div class = "image_wrapper image_fr" >< span ></ span >
         #img("/images/tooplate_image_01.jpg" "image")
     </ div >
     < p >< em >Morbi congue lorem sit amet odio iaculis tincidunt. Donec nibh, molestie nec pellentesque non, in diam. Class aptent taciti sociosqu ad litora torquent per conubia nostra.</ em ></ p >
     < p >Aliquam et augue et odio luctus posuere sit amet et nisi. Maecenas, est sit amet convallis consectetur, lacus ligula elementum lacus, ut fermentum elit sem et nisi. Duis eu elit tortor, sed condimentum nulla. Phasellus varius posuere adipiscing. Mauris sodales ullamcorper. Validate < a href = "http://validator.w3.org/check?uri=referer" rel = "nofollow" >< strong >XHTML</ strong ></ a > and < a href = "http://jigsaw.w3.org/css-validator/check/referer" rel = "nofollow" >< strong >CSS</ strong ></ a >.</ p >
     < div class = "cleaner h40" ></ div >
     #@box330("float_l")
         < h4 >what our customers say< span >Testimonial</ span ></ h4 >
         < blockquote >
         < p >Fusce nec felis id lacus sollicitudin vulputate. Sed vitae elit at diam vestibulum ullamcorper et nec quam. Aenean eit ut luctus sit amet, elementum quis enim. Proin tincidunt, arcu id pellentesque accumsan, neque dolor imperdiet ligula, quis viverra tellus nulla a odio. Curabitur vitae enim risus, at placerat turpis. Mauris feugiat suscipit tempus fringilla, felis in velit.</ p >
 
         < cite >Harry - < span >Senior Webmaster</ span ></ cite >
         </ blockquote >
         < a href = "#" class = "more" >more</ a >
     #end
     #@box330("float_r")
         < h4 >what we do< span >Services</ span ></ h4 >
         < p > Lorem ipsum dolor sit amet, consectetur adipiscing elit eget elementum lectus varius sed.</ p >
         < ul class = "tooplate_list" >
             < li >Morbi quis lorem risus</ li >
             < li >Suspendisse cursus</ li >
             < li >Donec at viverra</ li >
             < li >Proin eget purus ante</ li >
         </ ul >
         < a href = "#" class = "more" >more</ a >
     #end
#end



日志:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pageTitle("Blog" "Blog")
 
 
#@tooplateMiddleSub()
< h2 >Our Blog Posts</ h2 >
< p >Vestibulum eleifend consequat laoreet. Pellentesque vel orci sapien. Duis lacus ipsum, pretium ut accumsan in, tempor
     nec mauris. Aenean accumsan placerat elit, sit amet faucibus ante commodo a. In et neque nibh, ac tristique
     dui. </ p >
#end
 
#@tooplateContent()
     #@postBos("20" "Lorem ipsum dolor sit amet" "/images/tooplate_image_02.jpg" "Image 02" ["Templates","Freebie"] "148")
 
         < p >Vestibulum adipiscing tempus elit eu condimentum. Fusce at mi felis. Etiam sed velit nibh. Nunc bibendum
             justo elementum auctor. Donec at magna eu neque. Vestibulum ante ipsum primis in faucibus orci luctus et
             ultrices posuere cubilia. </ p >
     #end
 
     #@postBos("17" "Etiam gravida sagittis lacus" "/images/tooplate_image_03.jpg" "Image 03" ["CSS Templates","Web Design"] "128")
 
     < p >Ellentesque vitae velit eu lectus rhoncus tincidunt. Phasellus dictum dignissim sapien et dapibus. Sed
         egestas consequat mauris, orci tincidunt sit amet. Donec pharetra porta ultrices. Sed sit amet lectus
         libero, at porttitor odio. Validate < a href = "http://validator.w3.org/check?uri=referer"
                                                rel = "nofollow" >< strong >XHTML</ strong ></ a > and < a
                 href = "http://jigsaw.w3.org/css-validator/check/referer" rel = "nofollow" >< strong >CSS</ strong ></ a >.</ p >
     #end
 
     #@postBos("10" "Aenean vitae velit eget" "/images/tooplate_image_04.jpg" "Image 04" ["Illustrations","Graphics"] "208")
 
     < p >Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin gravida
         ornare mauris ac lobortis. Praesent elit neque, lacinia eget interdum eu. Phasellus posuere nisl et odio
         egestas ac tristique justo ultrices. </ p >
     #end
#end

画廊:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pageTitle("Gallery" "Gallery")
 
#@tooplateMiddleSub()
< h2 >Our Gallery</ h2 >
< p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porta adipiscing libero, eget elementum lectus
     varius sed. Aliquam metus urna, dignissim quis posuere at, posuere eget mauris. Vestibulum laoreet sodales tellus
     nec mollis. Validate < a href = "http://validator.w3.org/check?uri=referer" rel = "nofollow" >< strong >XHTML</ strong ></ a >
     and < a href = "http://jigsaw.w3.org/css-validator/check/referer" rel = "nofollow" >< strong >CSS</ strong ></ a >.</ p >
#end
 
#@tooplateContent()
     #@gallery()
     #galleryBox("/images/gallery/image_01_l.jpg" "/images/gallery/image_01_s.jpg" "Nunc et tellus id risus ultrices" "Image 01" "Nunc et tellus id risus ultrices")
     #galleryBox("/images/gallery/image_02_l.jpg" "/images/gallery/image_02_s.jpg" "Nunc et tellus id risus ultrices" "Image 02" "Nunc et tellus id risus ultrices")
     #galleryBox("/images/gallery/image_03_l.jpg" "/images/gallery/image_03_s.jpg" "Nunc et tellus id risus ultrices" "Image 03" "Nunc et tellus id risus ultrices" "gb_rmb")
     #galleryBox("/images/gallery/image_04_l.jpg" "/images/gallery/image_04_s.jpg" "Nunc et tellus id risus ultrices" "Image 04" "Nunc et tellus id risus ultrices")
     #galleryBox("/images/gallery/image_05_l.jpg" "/images/gallery/image_05_s.jpg" "Nunc et tellus id risus ultrices" "Image 05" "Nunc et tellus id risus ultrices")
     #galleryBox("/images/gallery/image_06_l.jpg" "/images/gallery/image_06_s.jpg" "Nunc et tellus id risus ultrices" "Image 06" "Nunc et tellus id risus ultrices" "gb_rmb")
     #end
#end

三、运行

首页

关于

日志

画廊

联系我们

四、总结

上面的完整示例展现了采用Tiny框架开发页面的完整过程,下面总结一下需要说明的一些内容:

  1. 上面展示采用的模板引擎是TinyTemplate,当然也支持Velocity,但是推荐使用TinyTemplate,因为执行速度更快、功能更强、更容易使用
  2. 布局支持多重嵌套,上面的示例中有两层布局,根上的解决js、css引入,标题,网站图标等部分的内容,/page/目录中的解决网站的整体结构部分的内容,随着网站的复杂,可以做更多层的布局,使得很多页面共用的部分都放在布局文件中
  3. xxx.ui.xml定义了UI组件包的内容及其依赖关系,UI引擎会自动根据ui组件包的定义对js及css进行引入、整合、压缩。
  4. 整个页面只引入一个css和一个js文件,避免引入文件数太多导致的性能下降,同时提供了压缩,提升网络传输效率(这个例子中的文件都已压缩,因此压缩率不高)。
  5. page文件是用来编写展示内容的页面,在显示.page文件时,有两种方式,一种是.pagelet方式,一种是.page方式,区别在于用.page方式访问时,会渲染布局,而pagelet方式不会渲染布局,适合于Ajax方式使用。
  6. 整个网站在重构完成之后,没有一段内容是重复的,真正做到Tiny框架所说的DRY原则。
  7. 所有对上层布局文件的修改都会对所有下层页面产生影响,真正做到Tiny框架所说的下级服从上级原则。
  8. 越到底层的开发人员接触的越少,真正的页面编写文件,只需要从控制层转过来的数据再利用宏去显示内容即可,可以避免接触js,css,html等相关内容。(这一点在示例中还没有做到,毕竟示例是一个静态网站),真正做到Tiny框架所说的减法原则,越到下面会的技能越少。
  9. 实际上框架也支持某个页面不服从上层布局的限制,但是我们不推荐这么做,因此这里没有展示这种用法。

采用Tiny框架制作前台,需要考虑好如下角色的协作:

  1. 美工:用于进行界面设计,页面切分
  2. UI组件包开发工程师:根据功能特性,把具有不同功能特性的js,css,image等放在一个jar包中 ,并编写对应的xxx.ui.xml文件,并设定好依赖关系,如果需要还需要编写公共的宏文件,用于方便别人使用,并隔离功能与具体的实现,使得后续的开发工程师尽量少的接触css,js。
  3. 业务组件开发工程师:根据功能特性,把页面中的一些比较业务化的,封装成业务组件,最终暴露的接口是一个名字及一些数据的输入,使得最终的界面开发工程师尽可能少的接触原生的html。
  4. 界面开发工程师:不关心界面展现的具体技术,利用UI组件包及业务组件开发工程师开发的组件,再加上控制层传过来的数据来编写最终的展现页面。

通过上面的分工,使得不同的开发人员关注于不同的技术细节,从而最大化的提升最终界面开发工程师的开发效率,同时因为有了一定的封装性,可以使得底层的变化不致于影响上层开发人员的工作成果。

相关文章
|
15天前
|
编解码 前端开发 JavaScript
构建高效响应式Web界面:现代前端框架的比较
【4月更文挑战第9天】在移动设备和多样屏幕尺寸盛行的时代,构建能够适应不同视口的响应式Web界面变得至关重要。本文深入探讨了几种流行的前端框架——Bootstrap、Foundation和Tailwind CSS,分析它们在创建响应式设计中的优势与局限。通过对比这些框架的栅格系统、组件库和定制化能力,开发者可以更好地理解如何选择合适的工具来优化前端开发流程,并最终实现高性能、跨平台兼容的用户界面。
|
21天前
|
监控 JavaScript 前端开发
《理解 WebSocket:Java Web 开发的实时通信技术》
【4月更文挑战第4天】WebSocket是Java Web实时通信的关键技术,提供双向持久连接,实现低延迟、高效率的实时交互。适用于聊天应用、在线游戏、数据监控和即时通知。开发涉及服务器端实现、客户端连接及数据协议定义,注意安全、错误处理、性能和兼容性。随着实时应用需求增加,WebSocket在Java Web开发中的地位将更加重要。
|
6天前
|
JSON Java fastjson
Spring Boot 底层级探索系列 04 - Web 开发(2)
Spring Boot 底层级探索系列 04 - Web 开发(2)
15 0
|
6天前
|
安全 编译器 PHP
PHP 8.1版本发布:引领Web开发新潮流
PHP编程语言一直是Web开发的主力军,而最新发布的PHP 8.1版本则为开发者们带来了更多创新和便利。本文将介绍PHP 8.1版本的主要特性,包括更快的性能、新的语言功能和增强的安全性,以及如何利用这些功能来提升Web应用程序的质量和效率。
|
9天前
|
PHP
web简易开发——通过php与HTML+css+mysql实现用户的登录,注册
web简易开发——通过php与HTML+css+mysql实现用户的登录,注册
|
10天前
|
前端开发 数据挖掘 API
使用Python中的Flask框架进行Web应用开发
【4月更文挑战第15天】在Python的Web开发领域,Flask是一个备受欢迎的轻量级Web框架。它简洁、灵活且易于扩展,使得开发者能够快速地构建出高质量的Web应用。本文将深入探讨Flask框架的核心特性、使用方法以及在实际开发中的应用。
|
19天前
|
安全 前端开发 Java
Java Web开发知识点学习总结
Java Web开发涉及Java基础、Servlet、JSP、数据库操作(SQL+JDBC)、MVC设计模式、Spring框架、Hibernate ORM、Web服务(SOAP&RESTful)、安全认证(HTTP Basic/Digest/OAuth)及性能优化(缓存、异步、负载均衡)。
17 3
|
21天前
|
编解码 前端开发 开发者
构建响应式Web界面:Flexbox与Grid布局的深度对比
【4月更文挑战第4天】 在现代前端开发中,构建灵活且响应式的用户界面是至关重要的。随着移动设备浏览量的增加,能够适应不同屏幕尺寸和分辨率的布局技术变得必不可少。Flexbox和Grid是CSS提供的两种强大的布局机制,它们各自以独特的方式解决了响应式设计的挑战。本文将深入探讨Flexbox和Grid的核心概念、使用场景和性能考量,为开发者提供在面对不同布局需求时做出明智选择的依据。
|
22天前
|
XML JSON JavaScript
使用JSON和XML:数据交换格式在Java Web开发中的应用
【4月更文挑战第3天】本文比较了JSON和XML在Java Web开发中的应用。JSON是一种轻量级、易读的数据交换格式,适合快速解析和节省空间,常用于API和Web服务。XML则提供更强的灵活性和数据描述能力,适合复杂数据结构。Java有Jackson和Gson等库处理JSON,JAXB和DOM/SAX处理XML。选择格式需根据应用场景和需求。
|
26天前
|
前端开发 JavaScript 数据管理
描述一个使用Python开发Web应用程序的实际项目经验,包括所使用的框架和技术栈。
使用Flask开发Web应用,结合SQLite、Flask-SQLAlchemy进行数据管理,HTML/CSS/JS(Bootstrap和jQuery)构建前端。通过Flask路由处理用户请求,模块化代码提高可维护性。unittest进行测试,开发阶段用内置服务器,生产环境可选WSGI服务器或容器化部署。实现了用户注册登录和数据管理功能,展示Python Web开发的灵活性和效率。
14 4