HTML5广义上讲是指包括HTML、CSS和JavaScript在内的一套技术组合.主要用于web网页应用.更适合于移动web网页开发.
HTML 5有两大特点:
首先,强化了 Web 网页的表现性能。
其次,追加了本地数据库等 Web 应用的功能。
页面代码实现 weding.html
1 | <html xmlns= "http://www.w3.org/1999/xhtml" > |
2 | <head> |
3 | <title>婚庆主页</title> |
4 | <meta http-equiv= "content-type" content= "text/html; charset=utf-8" > |
5 | <meta name= "viewport" content= "width=device-width, minimum-scale=1.0, maximum-scale=2.0,user-scalable=yes" > |
6 | <!--<meta name= "viewport" content= "width=640, initial-scale=0.5,maximum-scale=0.5" />--> |
7 | <meta name= "apple-mobile-web-app-capable" content= "YES" > |
8 | <link rel= "stylesheet" href= "mycss.css" type= "text/css" /> |
9 |
10 | </head> |
11 |
12 | <body bgcolor= "#680011" > |
13 |
14 | <div class = "wrapcontain" style= "width: 300px;padding: 10px;padding-top: 0px;margin: 0 auto;background-color:#680011;" > |
15 | <div class = "imgTop" > |
16 | <img class = "imgtop_bg" src= "./img/index_top_bg.png" /> |
17 | <img class = "imgtop_lb" src= "./img/index_microphone.png" /> |
18 | <h3 class = "p3" > |
19 | <p id= "sp11" class = "sp1" >离我们婚礼</p> |
20 | <p class = "sp2" > |
21 | 还有<span class = "sp3" > 35 </span>天 |
22 | </p> |
23 | </h3> |
24 | </div> |
25 |
26 | <div class = "imgShow" > |
27 |
28 | <img src= "./img/index_yaoqinghan.png" /> |
29 | <img src= "./img/index_zhufuqiang.png" /> |
30 | <img src= "./img/index_yaoyiyao.png" /> |
31 | <img src= "./img/index_hunsha.png" /> |
32 | </div> |
33 |
34 | <div class = "footer" > |
35 |
36 | <a href= "###" >婚礼承办方:成都幸福公社婚庆公司<img |
37 | src= "./img/redRightarrow.png" /></a> |
38 |
39 | </div> |
40 | </div> |
41 |
42 | </body> |
43 | </html> |
css代码 mycss.css
1 | .imgTop { |
2 | width: 320px; |
3 | margin-left: -10px; |
4 | margin-right: -10px; |
5 | min-height: 200px; |
6 | position:relative; |
7 | border-bottom:1px solid #ffeeac; |
8 | } |
9 |
10 | .imgTop .imgtop_bg{ |
11 | width: 100 %; |
12 | } |
13 |
14 | .imgTop .imgtop_lb { |
15 | margin-top: 10px; |
16 | margin-left: 10px; |
17 | position: absolute;left: 10px; top:10px; |
18 | } |
19 | .p3 { |
20 | width: 118px; |
21 | height: 22px; |
22 |
23 | /* background-color: #ff6766; */ |
24 | /* margin: 10px; */ |
25 | /* float: right;*/ |
26 | /* margin-top:110px; */ |
27 |
28 | padding: 30px; |
29 | position: absolute; |
30 | right: 10px; |
31 | bottom : 0px; |
32 |
33 | } |
34 |
35 | .sp1 { |
36 | font-size: 10px; |
37 | color: #ffeeac; |
38 | } |
39 |
40 | .sp2 { |
41 | font-size: 10px; |
42 | color: #ffeeac; |
43 | text-align: right; |
44 | } |
45 |
46 | .sp3 { |
47 | font-size: 20px; |
48 | } |
49 |
50 | .imgShow { |
51 | width: 320px; |
52 | height: 210px; |
53 | overflow: hidden; |
54 | margin-left: -10px; |
55 | margin-top: 14px; |
56 |
57 | } |
58 |
59 | .imgShow img { |
60 | width: 145px; |
61 | height: 110px; |
62 | display: inline-block; |
63 | float : left; |
64 | margin-left: 10px; |
65 | margin-bottom: 10px; |
66 | } |
67 | .footer { |
68 | margin-top: 14px; |
69 | text-align: center; |
70 | } |
71 |
72 | .footer a { |
73 | color: #92192d; |
74 | font-size: 14px; |
75 | } |
76 |
77 | .footer img { |
78 | width: 20px; |
79 | display: inline-block; |
80 | position: relative; |
81 | top: 2px; |
82 | margin-left: 8px; |
83 | } |
通过上述步骤我们已经实现页面效果,接着我们将把界面显示到Android应用中,需要一个叫webView的控件,我们看下代码.
activity_weding_layout.xml
1 | <?xml version= "1.0" encoding= "utf-8" ?> |
2 | <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" |
3 | android:layout_width= "match_parent" |
4 | android:layout_height= "match_parent" |
5 | android:orientation= "vertical" > |
6 |
7 | <WebView |
8 | android:id= "@+id/weding_webview" |
9 | android:layout_width= "match_parent" |
10 | android:layout_height= "match_parent" /> |
11 |
12 | </LinearLayout> |
WebViewActivity.java
1 | public class WedingActivity extends Activity { |
2 | private WebView mWebView; |
3 | private String url = "http://www.warmtel.com/html/weding.html" ; //上面实现的网页 |
4 |
5 | @Override |
6 | protected void onCreate(Bundle savedInstanceState) { |
7 | super .onCreate(savedInstanceState); |
8 | requestWindowFeature(Window.FEATURE_NO_TITLE); |
9 | setContentView(R.layout.activity_weding_layout); |
10 |
11 | mWebView = (WebView) findViewById(R.id.weding_webview); |
12 |
13 | mWebView.loadUrl(url); |
14 |
15 | } |
16 | } |