操屁眼的视频在线免费看,日本在线综合一区二区,久久在线观看免费视频,欧美日韩精品久久综

新聞資訊

    1、定義

    <meta> 標(biāo)簽提供關(guān)于 HTML 文檔的元數(shù)據(jù)。它不會顯示在頁面上,但是對于機器是可讀的。可用于瀏覽器(如何顯示內(nèi)容或重新加載頁面),搜索引擎(關(guān)鍵詞),或其他 web 服務(wù)。

    2、作用

    meta里的數(shù)據(jù)是供機器解讀的,告訴機器該如何解析這個頁面,還有一個用途是可以添加服務(wù)器發(fā)送到瀏覽器的http頭部內(nèi)容,例如我們?yōu)轫撁嬷刑砑尤缦耺eta標(biāo)簽:


    1. <meta http-equiv="charset" content="iso-8859-1">
    2. <meta http-equiv="expires" content="31 Dec 2008">

    瀏覽器的頭部就會包括這些:


    1. charset:iso-8859-1
    2. expires:31 Dec 2008

    只有瀏覽器可以接受這些附加的頭部字段,并能以適當(dāng)?shù)姆绞绞褂盟鼈儠r,這些字段才有意義。

    3、meta的必需屬性和可選屬性

    meta的必需屬性是content,當(dāng)然并不是說meta標(biāo)簽里一定要有content,而是當(dāng)有http-equiv或name屬性的時候,一定要有content屬性對其進行說明。例如:

    必需屬性

    <meta name="keywords" content="HTML,ASP,PHP,SQL">

    這里面content里的屬性就是對keywords進行的說明,所以呢也可以理解成一個鍵值對吧,就是{keywords:"HTML,ASP,PHP,SQL"}。

    可選屬性

    在W3school中,對于meta的可選屬性說到了三個,分別是http-equiv、name和scheme。考慮到scheme不是很常用,所以就只說下前兩個屬性吧。

    http-equiv

    http-equiv屬性是添加http頭部內(nèi)容,對一些自定義的,或者需要額外添加的http頭部內(nèi)容,需要發(fā)送到瀏覽器中,我們就可以是使用這個屬性。在上面的meta作用中也有簡單的說明,那么現(xiàn)在再舉個例子。例如我們不想使用js來重定向,用http頭部內(nèi)容控制,那么就可以這樣控制:

    <meta http-equiv="Refresh" content="5;url=http://blog.yangchen123h.cn" />

    在頁面中加入這個后,5秒鐘后就會跳轉(zhuǎn)到指定頁面啦,效果可看W3school的例子

    name

    第二個可選屬性是name,這個屬性是供瀏覽器進行解析,對于一些瀏覽器兼容性問題,name屬性是最常用的,當(dāng)然有個前提就是瀏覽器能夠解析你寫進去的name屬性才可以,不然就是沒有意義的。還是舉個例子吧:

    <meta name="renderer" content="webkit">

    這個meta標(biāo)簽的意思就是告訴瀏覽器,用webkit內(nèi)核進行解析,當(dāng)然前提是瀏覽器有webkit內(nèi)核才可以,不然就是沒有意義的啦。當(dāng)然看到這個你可能會有疑問,這個renderer是從哪里冒出來的,我要怎么知道呢?這個就是在對應(yīng)的瀏覽器的開發(fā)文檔里就會有表明的,例如這個renderer是在360瀏覽器里說明的。360瀏覽器內(nèi)核控制Meta標(biāo)簽說明文檔

    常用meta標(biāo)簽大總結(jié)

    接下來就是常用的meta標(biāo)簽大總結(jié)啦,我會盡可能的做到全

    charset

    charset是聲明文檔使用的字符編碼,解決亂碼問題主要用的就是它,值得一提的是,這個charset一定要寫第一行,不然就可能會產(chǎn)生亂碼了。

    charset有兩種寫法


    1. <meta charset="utf-8">
    2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    兩個都是等效的。

    百度禁止轉(zhuǎn)碼

    百度會自動對網(wǎng)頁進行轉(zhuǎn)碼,這個標(biāo)簽是禁止百度的自動轉(zhuǎn)碼

    <meta http-equiv="Cache-Control" content="no-siteapp" />

    SEO 優(yōu)化部分


    1. <!-- 頁面標(biāo)題<title>標(biāo)簽(head 頭部必須) -->
    2. <title>your title</title>
    3. <!-- 頁面關(guān)鍵詞 keywords -->
    4. <meta name="keywords" content="your keywords">
    5. <!-- 頁面描述內(nèi)容 description -->
    6. <meta name="description" content="your description">
    7. <!-- 定義網(wǎng)頁作者 author -->
    8. <meta name="author" content="author,email address">
    9. <!-- 定義網(wǎng)頁搜索引擎索引方式,robotterms 是一組使用英文逗號「,」分割的值,通常有如下幾種取值:none,noindex,nofollow,all,index和follow。 -->
    10. <meta name="robots" content="index,follow">

    viewport

    viewport主要是影響移動端頁面布局的,例如:


    1. <meta name="viewport" content="width=device-width, initial-scale=1.0">

    content 參數(shù):

    • width viewport 寬度(數(shù)值/device-width)
    • height viewport 高度(數(shù)值/device-height)
    • initial-scale 初始縮放比例
    • maximum-scale 最大縮放比例
    • minimum-scale 最小縮放比例
    • user-scalable 是否允許用戶縮放(yes/no)

    各瀏覽器平臺

    Microsoft Internet Explorer


    1. <!-- 優(yōu)先使用最新的ie版本 -->
    2. <meta http-equiv="x-ua-compatible" content="ie=edge">
    3. <!-- 是否開啟cleartype顯示效果 -->
    4. <meta http-equiv="cleartype" content="on">
    5. <meta name="skype_toolbar" content="skype_toolbar_parser_compatible">
    6. <!-- Pinned Site -->
    7. <!-- IE 10 / Windows 8 -->
    8. <meta name="msapplication-TileImage" content="pinned-tile-144.png">
    9. <meta name="msapplication-TileColor" content="#009900">
    10. <!-- IE 11 / Windows 9.1 -->
    11. <meta name="msapplication-config" content="ieconfig.xml">

    Google Chrome


    1. <!-- 優(yōu)先使用最新的chrome版本 -->
    2. <meta http-equiv="X-UA-Compatible" content="chrome=1" />
    3. <!-- 禁止自動翻譯 -->
    4. <meta name="google" value="notranslate">

    360瀏覽器


    1. <!-- 選擇使用的瀏覽器解析內(nèi)核 -->
    2. <meta name="renderer" content="webkit|ie-comp|ie-stand">

    UC手機瀏覽器

    UCBrowser_U3_API

    QQ手機瀏覽器


    1. <!-- 鎖定屏幕在特定方向 -->
    2. <meta name="x5-orientation" content="landscape/portrait">
    3. <!-- 全屏顯示 -->
    4. <meta name="x5-fullscreen" content="true">
    5. <!-- 頁面將以應(yīng)用模式顯示 -->
    6. <meta name="x5-page-mode" content="app">

    Apple iOS


    1. <!-- Smart App Banner -->
    2. <meta name="apple-itunes-app" content="app-id=APP_ID,affiliate-data=AFFILIATE_ID,app-argument=SOME_TEXT">
    3. <!-- 禁止自動探測并格式化手機號碼 -->
    4. <meta name="format-detection" content="telephone=no">
    5. <!-- Add to Home Screen添加到主屏 -->
    6. <!-- 是否啟用 WebApp 全屏模式 -->
    7. <meta name="apple-mobile-web-app-capable" content="yes">
    8. <!-- 設(shè)置狀態(tài)欄的背景顏色,只有在 “apple-mobile-web-app-capable” content=”yes” 時生效 -->
    9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
    10. <!-- 添加到主屏后的標(biāo)題 -->
    11. <meta name="apple-mobile-web-app-title" content="App Title">

    Google Android


    1. <meta name="theme-color" content="#E64545">
    2. <!-- 添加到主屏 -->
    3. <meta name="mobile-web-app-capable" content="yes">
    4. <!-- More info: https://developer.chrome.com/multidevice/android/installtohomescreen -->

    App Links


    1. <!-- iOS -->
    2. <meta property="al:ios:url" content="applinks://docs">
    3. <meta property="al:ios:app_store_id" content="12345">
    4. <meta property="al:ios:app_name" content="App Links">
    5. <!-- Android -->
    6. <meta property="al:android:url" content="applinks://docs">
    7. <meta property="al:android:app_name" content="App Links">
    8. <meta property="al:android:package" content="org.applinks">
    9. <!-- Web Fallback -->
    10. <meta property="al:web:url" content="http://applinks.org/documentation">
    11. <!-- More info: http://applinks.org/documentation/ -->

    最后——移動端常用的meta


    1. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    2. <meta name="apple-mobile-web-app-capable" content="yes" />
    3. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    4. <meta name="format-detection"content="telephone=no, email=no" />
    5. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    6. <meta name="apple-mobile-web-app-capable" content="yes" /><!-- 刪除蘋果默認(rèn)的工具欄和菜單欄 -->
    7. <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 設(shè)置蘋果工具欄顏色 -->
    8. <meta name="format-detection" content="telphone=no, email=no" /><!-- 忽略頁面中的數(shù)字識別為電話,忽略email識別 -->
    9. <!-- 啟用360瀏覽器的極速模式(webkit) -->
    10. <meta name="renderer" content="webkit">
    11. <!-- 避免IE使用兼容模式 -->
    12. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    13. <!-- 針對手持設(shè)備優(yōu)化,主要是針對一些老的不識別viewport的瀏覽器,比如黑莓 -->
    14. <meta name="HandheldFriendly" content="true">
    15. <!-- 微軟的老式瀏覽器 -->
    16. <meta name="MobileOptimized" content="320">
    17. <!-- uc強制豎屏 -->
    18. <meta name="screen-orientation" content="portrait">
    19. <!-- QQ強制豎屏 -->
    20. <meta name="x5-orientation" content="portrait">
    21. <!-- UC強制全屏 -->
    22. <meta name="full-screen" content="yes">
    23. <!-- QQ強制全屏 -->
    24. <meta name="x5-fullscreen" content="true">
    25. <!-- UC應(yīng)用模式 -->
    26. <meta name="browsermode" content="application">
    27. <!-- QQ應(yīng)用模式 -->
    28. <meta name="x5-page-mode" content="app">
    29. <!-- windows phone 點擊無高光 -->
    30. <meta name="msapplication-tap-highlight" content="no">
    31. <!-- 適應(yīng)移動端end -->

    第一種方法:在XML文件下添加:

    android:focusable="true" 
    android:focusableInTouchMode="true"
    

    第二種方法:直接關(guān)閉輸入法

    在onCreate中加上:

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    

    第三中方法:在Edittext中設(shè)置

    .setInputType(InputType.TYPE_NULL);
    

    但是會實現(xiàn)效果,但是會導(dǎo)致光標(biāo)也無法顯示,如果想顯示光標(biāo),你就需要定義一個方法,在方法內(nèi)setInputType(禁止)

    public void disableShowInput() {
     if (android.os.Build.VERSION.SDK_INT <=10) {
     editText.setInputType(InputType.TYPE_NULL);
     } else {
     Class<EditText> cls=EditText.class;
     Method method;
     try {
     method=cls.getMethod("setShowSoftInputOnFocus", boolean.class);
     method.setAccessible(true);
     method.invoke(editText, false)
     } catch (Exception e) {//TODO: handle exception
     }
     try {
     method=cls.getMethod("setSoftInputShownOnFocus", boolean.class);
     method.setAccessible(true);
     method.invoke(editText, false);
     } catch (Exception e) {//TODO: handle exception
     }
     }
     }
    

    這時 你會發(fā)現(xiàn),光標(biāo)是出來了 但是輸入文字,光標(biāo)永遠(yuǎn)在前面,怎么辦,解決思路,監(jiān)聽文字文本內(nèi)容變化監(jiān)聽方法,在afterTextChanged文字輸入完后,把光標(biāo)移到最后.setSelection(Edittext,Edittext.length());看代碼:

     Edittext.addTextChangedListener(watcher);
     private TextWatcher watcher=new TextWatcher() {
     @Override
     public void onTextChanged(CharSequence s, int start, int before,
     int count) {
     }
     @Override
     public void beforeTextChanged(CharSequence s, int start, int count,
     int after) {
     }
     @Override
     public void afterTextChanged(Editable s) {
     Edittext.setSelection(Edittext, Edittext.length());
     }
     };
    

    附加:重寫Edittext 在輸入框內(nèi)增加刪除文字按鈕,就是在http://lib.csdn.net/base/android系統(tǒng)的輸入框右邊加入一個小圖標(biāo),點擊小圖標(biāo)可以清除輸入框里面的內(nèi)容具體看代碼:

    import android.content.Context; 
    import android.graphics.drawable.Drawable; 
    import android.text.Editable; 
    import android.text.TextWatcher; 
    import android.util.AttributeSet; 
    import android.view.MotionEvent; 
    import android.view.View; 
    import android.view.View.OnFocusChangeListener; 
    import android.view.animation.Animation; 
    import android.view.animation.CycleInterpolator; 
    import android.view.animation.TranslateAnimation; 
    import android.widget.EditText; 
     
    public class RMEditText extends EditText implements 
     OnFocusChangeListener, TextWatcher { 
     /** 
     * 刪除按鈕的引用 
     */ 
     private Drawable mClearDrawable; 
     /** 
     * 控件是否有焦點 
     */ 
     private boolean falg; 
     
     public ClearEditText(Context context) { 
     this(context, null); 
     } 
     
     public ClearEditText(Context context, AttributeSet attrs) { 
     //這里構(gòu)造方法也很重要,不加這個很多屬性不能再XML里面定義 
     this(context, attrs, android.R.attr.editTextStyle); 
     } 
     
     public ClearEditText(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
     init(); 
     } 
     private void init() { 
     //獲取EditText的DrawableRight,假如沒有設(shè)置我們就使用默認(rèn)的圖片 
     mClearDrawable=getCompoundDrawables()[2]; 
     if (mClearDrawable==null) { 
    // throw new NullPointerException("You can add drawableRight attribute in XML"); 
     mClearDrawable=getResources().getDrawable(R.drawable.delete_selector); 
     } 
     mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight()); 
     //默認(rèn)設(shè)置隱藏圖標(biāo) 
     setClearIconVisible(false); 
     //設(shè)置焦點改變的監(jiān)聽 
     setOnFocusChangeListener(this); 
     //設(shè)置輸入框里面內(nèi)容發(fā)生改變的監(jiān)聽 
     addTextChangedListener(this); 
     } 
     /** 
     * 因為我們不能直接給EditText設(shè)置點擊事件,所以我們用記住我們按下的位置來模擬點擊事件 
     * 當(dāng)我們按下的位置 在 EditText的寬度 - 圖標(biāo)到控件右邊的間距 - 圖標(biāo)的寬度 和 
     * EditText的寬度 - 圖標(biāo)到控件右邊的間距之間我們就算點擊了圖標(biāo),豎直方向就沒有考慮 
     */ 
     @Override 
     public boolean onTouchEvent(MotionEvent event) { 
     if (event.getAction()==MotionEvent.ACTION_UP) { 
     if (getCompoundDrawables()[2] !=null) { 
     
     boolean touchable=event.getX() > (getWidth() - getTotalPaddingRight()) 
     && (event.getX() < ((getWidth() - getPaddingRight()))); 
     
     if (touchable) { 
     this.setText(""); 
     } 
     } 
     } 
     return super.onTouchEvent(event); 
     } 
     /** 
     * 當(dāng)ClearEditText焦點發(fā)生變化的時候,判斷里面字符串長度設(shè)置清除圖標(biāo)的顯示與隱藏 
     */ 
     @Override 
     public void onFocusChange(View v, boolean hasFocus) { 
     this.falg=hasFocus; 
     if (hasFocus) { 
     setClearIconVisible(getText().length() > 0); 
     } else { 
     setClearIconVisible(false); 
     } 
     } 
     /** 
     * 設(shè)置清除圖標(biāo)的顯示與隱藏,調(diào)用setCompoundDrawables為EditText繪制上去 
     * @param visible 
     */ 
     protected void setClearIconVisible(boolean visible) { 
     Drawable right=visible ? mClearDrawable : null; 
     setCompoundDrawables(getCompoundDrawables()[0], 
     getCompoundDrawables()[1], right, getCompoundDrawables()[3]); 
     } 
     /** 
     * 當(dāng)輸入框里面內(nèi)容發(fā)生變化的時候回調(diào)的方法 
     */ 
     @Override 
     public void onTextChanged(CharSequence s, int start, int count, 
     int after) { 
     if(falg){ 
     setClearIconVisible(s.length() > 0); 
     } 
     } 
     @Override 
     public void beforeTextChanged(CharSequence s, int start, int count, 
     int after) { 
     } 
     @Override 
     public void afterTextChanged(Editable s) { 
     } 
    } 
    

    在xml文件中這樣用

    <com.example.edittext.RMEditText 
     android:hint="輸入文字" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 
    </> 
    
    • setClearIconVisible()設(shè)置隱藏和顯示清除圖標(biāo)的方法,調(diào)用setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)來設(shè)置上下左右的圖標(biāo)
    • setOnFocusChangeListener(this) 為輸入框設(shè)置焦點改變監(jiān)聽,如果輸入框有焦點,我們判斷輸入框的值是否為空,為空就隱藏清除圖標(biāo),否則就顯示它
    • addTextChangedListener(this) 為輸入框設(shè)置內(nèi)容改變監(jiān)聽,其實很簡單呢,當(dāng)輸入框里面的內(nèi)容發(fā)生改變的時候,我們需要處理顯示和隱藏清除小圖標(biāo),里面的內(nèi)容長度不為0我們就顯示,否是就隱藏,但這個需要輸入框有焦點我們才改變顯示或者隱藏,為什么要需要焦點,比如我們一個登陸界面,我們保存了用戶名和密碼,在登陸界面onCreate()的時候,我們把我們保存的密碼顯示在用戶名輸入框和密碼輸入框里面,輸入框里面內(nèi)容發(fā)生改變,導(dǎo)致用戶名輸入框和密碼輸入框里面的清除小圖標(biāo)都顯示了,這顯然不是我們想要的效果,所以加了一個是否有焦點的判斷這塊可以參考
    • http://blog.csdn.net/xiaanming/article/details/11066685/# 這篇文章,還有動畫效果。
網(wǎng)站首頁   |    關(guān)于我們   |    公司新聞   |    產(chǎn)品方案   |    用戶案例   |    售后服務(wù)   |    合作伙伴   |    人才招聘   |   

友情鏈接: 餐飲加盟

地址:北京市海淀區(qū)    電話:010-     郵箱:@126.com

備案號:冀ICP備2024067069號-3 北京科技有限公司版權(quán)所有