如何在网页标题栏title加入logo图标?

打开某一个网页会在浏览器的标签栏处显示该网页的标题和图标,当网页被添加到收藏夹或者书签中时也会出现网页的图标,怎么在网页title左边显示网页的logo图标呢?

方法一是:找一个或者作一个ico文件,然后把文件的名字改为favicon.ico,像素大小为16*16,所使用的颜色不得超过16色,然后再把favicon.ico放到网站的根目录下就行了。

这样的话浏览器会不停的搜索您的网站的根目录,只要它一发现了名字叫做favicon.ico 这个文件,就会将该图标显示在访问者的地址栏和收藏夹列表中了。

另一种实现方法是在网页HEAD标记中添加如下代码:

标题栏:
<link rel="icon" href="ico地址" type="image/x-icon">
收藏夹:
<link rel="shortcut icon" href="ico地址" type="image/x-icon">

注意:图标要用 16*16 色的。。。

其实很多软件可以制作图标的,你在百度搜一下图标制作软件就可能了。

另外,如果将 16*16 的 bmp 文件改为 ico ,在WINDOWS 支持,但放在浏览器或别的软件就会出错 。

如:<HEAD> <LINK REL=”SHORTCUT ICON” HREF=”http://www.anjoweb.com/favicon.ico”></HEAD>使用这个做法的话,就不一定要把图形文件放在网站的根目录下面了,你可以放在任何位置,甚至直接连结到其他网站上面的图形文件也可以,而且图形文件的文件 名也不一定要叫做 favicon.ico,可以自己随便取。 不过要注意的是使用这个做法的话,只有在把有加入上面 HTML 语法的页面加入书签的时候才会有作用。

我开始使用的是第一种方法,当时没有注意到图标的像素大小限制,用的是128*128的ico图标,在Chrome浏览器中显示正常,不过在IE中不显示。所以还是建议按规则生成图标

在这里顺便给大家推荐一个在线ICO图标制作的网址:

http://www.ico.la/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CollapsingToolbarLayout中显示工具的标志,图标标题和副标题,你需要在布局文件中使用CollapsingToolbarLayout和Toolbar。 在Toolbar中设置logo标题,你可以使用以下代码: ```xml <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:logo="@drawable/logo" android:title="Title"/> ``` 要在CollapsingToolbarLayout中显示标题和副标题,你可以使用以下代码: ```xml <android.support.design.widget.CollapsingToolbarLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin"/> <ImageView android:layout_width="match_parent" android:layout_height="200dp" android:src="@drawable/background_image" app:layout_collapseMode="parallax"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Title" app:layout_collapseMode="pin"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Subtitle" app:layout_collapseMode="pin"/> </android.support.design.widget.CollapsingToolbarLayout> ``` 在这个例子中,ImageView使用了parallax属性,允许图像在CollapsingToolbarLayout滚动时以不同的速度滚动。 注意:要使用CollapsingToolbarLayout和Toolbar,你需要在你的build.gradle文件中添加以下依赖项: ```gradle implementation 'com.android.support:design:28.0.0' ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值