當前位置:首頁 » 網頁前端 » 前端網頁頭部代碼
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

前端網頁頭部代碼

發布時間: 2022-05-02 21:53:54

❶ 求助,html5前端頭部問題

meta屬性在HTML中占據了很重要的位置。如:針對搜索引擎的SEO,文檔的字元編碼,設置刷新緩存等。雖然一些網頁可能沒有使用meta,但是作為正規軍,我們還是有必要了解一些meta的屬性,並且能夠熟練使用它們。
1、聲明文檔使用的字元編碼
<meta charset='utf-8'>11

2、聲明文檔的兼容模式
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 指示IE以目前可用的最高模式顯示內容
<meta http-equiv="X-UA-Compatible" content="IE=Emulate IE7" />指示IE使用 <!DOCTYPE> 指令確定如何呈現內容。標准模式指令以IE7 標准模式顯示,而 Quirks 模式指令以 IE5 模式顯示。1212

3、SEO 優化
<meta name="description" content="不超過150個字元" />頁面描述
<meta name="keywords" content="html5, css3, 關鍵字"/>頁面關鍵詞
<meta name="author" content="魔法小棧" />定義網頁作者
<meta name="robots" content="index,follow" />定義網頁搜索引擎索引方式,robotterms是一組使用英文逗號「,」分割的值,通常有如下幾種取值:none,noindex,nofollow,all,index和follow。12341234

4、為移動設備添加 viewport
<meta name ="viewport" content ="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
content 參數解釋:
width viewport 寬度(數值/device-width)
height viewport 高度(數值/device-height)
initial-scale 初始縮放比例
maximum-scale 最大縮放比例
minimum-scale 最小縮放比例
user-scalable 是否允許用戶縮放(yes/no)
minimal-ui iOS 7.1 beta 2 中新增屬性,可以在頁面載入時最小化上下狀態欄。這是一個布爾值,可以直接這樣寫:
<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">1234567891012345678910

5、iOS 設備
<meta name="apple-mobile-web-app-title" content="標題">添加到主屏後的標題(iOS 6 新增)
<meta name="apple-mobile-web-app-capable" content="yes" />是否啟用 WebApp 全屏模式
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />設置狀態欄的背景顏色
只有在 "apple-mobile-web-app-capable" content="yes" 時生效
content 參數:
default 默認值。
black 狀態欄背景是黑色。
black-translucent 狀態欄背景是黑色半透明。
設置為 default 或 black ,網頁內容從狀態欄底部開始。
設置為 black-translucent ,網頁內容充滿整個屏幕,頂部會被狀態欄遮擋。1234567891012345678910

6、iOS 圖標 rel 參數
apple-touch-icon 圖片自動處理成圓角和高光等效果。
apple-touch-icon-precomposed 禁止系統自動添加效果,直接顯示設計原圖。
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" />iPhone 和 iTouch,默認 57x57 像素,必須有
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/apple-touch-icon-72x72-precomposed.png" />iPad,72x72 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png" />Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png" />Retina iPad,144x144 像素,可以沒有,推薦大家使用
<meta name="apple-mobile-web-app-title" content="標題">title最好限制在六個中文長度內,超長的內容會被隱藏,添加到主屏後的標題(iOS 6 新增)12345671234567

7、iOS 啟動畫面
iPad 的啟動畫面是不包括狀態欄區域的。
iPad 豎屏 768 x 1004(標准解析度)
<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" />iPad 豎屏 1536x2008(Retina)
<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png" />iPad 橫屏 1024x748(標准解析度)
<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" />iPad 橫屏 2048x1496(Retina)
<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png" />
iPhone 和 iPod touch 的啟動畫面是包含狀態欄區域的。
iPhone/iPod Touch 豎屏 320x480 (標准解析度)
<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png" />iPhone/iPod Touch 豎屏 640x960 (Retina)
<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png" />iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina)
<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png" />
<link rel="apple-touch-startup-image" href="Startup.png" /> 當用戶點擊主屏圖標打開 WebApp 時,系統會展示啟動畫面,在未設置情況下系統會默認顯示該網站的首頁截圖,當然這個體驗不是很好

8、Windows 8
<meta name="msapplication-TileColor" content="#000"/> Windows 8 磁貼顏色
<meta name="msapplication-TileImage" content="icon.png"/>Windows 8 磁貼圖標1212

9、不常用的
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" />添加 RSS 訂閱
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" />添加 favicon icon
<meta name="format-detection" content="telephone=no" />禁止數字識自動別為電話號碼
<meta name="format-detection" content="email=no" />不讓android識別郵箱
<meta name="renderer" content="webkit">啟用360瀏覽器的極速模式(webkit)
<meta http-equiv="X-UA-Compatible" content="IE=edge">避免IE使用兼容模式
<meta name="HandheldFriendly" content="true">針對手持設備優化,主要是針對一些老的不識別viewport的瀏覽器,比如黑莓
<meta name="MobileOptimized" content="320">微軟的老式瀏覽器
<meta name="x5-orientation" content="portrait">QQ強制豎屏
<meta name="full-screen" content="yes">UC強制全屏
<meta name="x5-fullscreen" content="true">QQ強制全屏
<meta name="browsermode" content="application">UC應用模式
<meta name="x5-page-mode" content="app">QQ應用模式
<meta http-equiv="Cache-Control" content="no-siteapp" />禁止網路轉碼
<meta name="msapplication-tap-highlight" content="no">windows phone 點擊無高光
<meta name="keywords" content="" /> 關鍵字
<meta name="description" content="" /> 描述
<meta name="title" content="" /> 標題
<meta name="author" content="-06" /> 作者
<meta name="Copyright" content="" /> 公司
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 讓IE瀏覽器用最高級內核渲染頁面 還有用 Chrome 框架的頁面用webkit 內核
<meta name="apple-mobile-web-app-capable" content="yes"> IOS6全屏
<meta name="mobile-web-app-capable" content="yes"> Chrome高版本全屏
<meta name="renderer" content="webkit"> 讓360雙核瀏覽器用webkit內核渲染頁面
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari)202122232425

10、sns 社交標簽
參考微博API
<meta property="og:type" content="類型" />
<meta property="og:url" content="URL地址" />
<meta property="og:title" content="標題" />
<meta property="og:image" content="圖片" />
<meta property="og:description" content="描述" />1234512345

11、條件注釋判斷IE瀏覽器
<!--[if IE]>條件注釋區分非IE瀏覽器
<!--[if lt IE 7 ]><html class="oldie ie ie6"> <![endif]-->
<!--[if IE 7 ]><html class="oldie ie ie7"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html> <!--<![endif]-->
<!--[if lt IE 9]> <![endif]-->123456123456

12.如果頁面上出現很多http請求會自動轉換成https
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

❷ 前端設計頭部布局,下圖該怎麼進行頭部布局

上+下+中間突出部分絕對定位

❸ 怎麼優化前端代碼,讓百度高效識別移動頁面

優化前端代碼有一下幾點:
(1)CSS代碼簡寫。這里說的簡寫主要解決的問題是,網站代碼冗餘,去除不必要的空格等等。如果可以用一句表達的語言,就不要多出幾行代碼,符合W3C標准。
(2)同屬性提出
如果2個樣式帶有同樣的屬性,可以把同屬性單獨提出處理。例如A樣式和B樣式的字體顏色、大小、邊框都一樣,那麼就可以考慮提出。
(3)結構清晰優化
網站代碼清晰是指,把代碼分區處理:網站頭部、網站身體,網站底部,3個區域進行不同的布局。不同區間的代碼要區別總的選擇器,選擇不同顏色加以區分隔開處理。
代碼簡化,爬行的目錄層次淺,這樣加強了搜索引擎對代碼的友好程度,進而提高網站的權重,關鍵詞才會有良好的排名。如果代碼冗餘,煩瑣,搜索引擎也就關注的少了。

❹ 如何把web前端網頁做成自適應

1.首先,在網頁代碼的頭部,加入一行viewport元標簽。
viewport是網頁默認的寬度和高度,上面這行代碼的意思是,網頁寬度默認等於屏幕寬度(width=device-width),原始縮放比例(initial-scale=1)為1.0,即網頁初始大小占屏幕面積的100%。
所有主流瀏覽器都支持這個設置,包括IE9,對於那些老式瀏覽器(主要是IE6、7、8),需要使用css3-mediaqueries.js。
2、不使用絕對寬度由於網頁會根據屏幕寬度調整布局,所以不能使用絕對寬度的布局,也不能使用具有絕對寬度的元素。這一條非常重要。具體說,CSS代碼不能指定像素寬度:width:xxx px;
只能指定百分比寬度:width: xx%;或者width:auto;
3、相對大小的字體
字體也不能使用絕對大小(px),而只能使用相對大小(em)。
body {
font: normal 100% Helvetica, Arial, sans-serif;
}
上面的代碼指定,字體大小是頁面默認大小的100%,即16像素。
h1 {
font-size: 1.5em;
}
然後,h1的大小是默認大小的1.5倍,即24像素(24/16=1.5)。
small {
font-size: 0.875em;
}
small元素的大小是默認大小的0.875倍,即14像素(14/16=0.875)。

❺ 前端開發的代碼中HTML 是不是就是那些標簽,那css 和JS 又是分別那部分編碼呢

html = hyper text markup language,也就是超文本傳輸協議,網頁其實是一類文件,但是這類文件中夾雜了除了文字以外的很多東西,圖片,表格,樣式,鏈接,動畫,視頻,音樂,各種應用,小插件等等。標簽,這是是裡面的一種元素。

css,caseding style sheet,層疊式樣本表,是針對上面這個文本的格式來設置的一個文件,一般在文件頭部,總體布局的作用

js,javascript,相當於是在html中使用各種觸發的函數。也可以使用vbscript,這樣就可以對用戶電腦產生操作,比如說createobject等等,這也就是一部分網頁要小心進入的原因,他有可能在看你電腦裡面的東西

這些你可以在這個網站上面學,是免費的網頁鏈接

❻ 前端顯示正常,頁面源代碼裡面的文字是亂的,是怎麼回事呀

首先你要知道為什麼會照成亂碼的原因。
1、HTML代碼裡面的頭部原信息沒有寫。即(<meta charset="utf-8">)或者是gb2312.
2、在頁面文件保存的時候,會選擇頁面保存的編碼格式。
3、最重要的一點就是。以上兩個格式需要一致。否則出現亂碼。

❼ 網站前端問題,網頁頂部廣告怎麼加

第一是畫效果圖第二是把效果圖轉換成網頁FIREWORK第三就是要寫程序,語言有(asp,php,aspx......)第四就是買空間域名做好綁定和指向最後就是要備案,這樣網站就可以訪問了%D%A