php 如何通过 CSS 添加徽标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14499492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I add a logo through CSS?
提问by user1436885
How can I add my logo into my css stylesheet as I have tons of php pages and I dont want to manually add in one by one.
如何将我的徽标添加到我的 css 样式表中,因为我有大量的 php 页面并且我不想手动一个一个地添加。
Basically I wan to have a global function so I just need to put in one page.
基本上我想要一个全局函数,所以我只需要放入一页。
回答by Dipesh Parmar
In css use backgroundas below.
在 css 中使用background如下。
.logo { background : url(path_to_logo); }
回答by Djave
Or if your logo was say 60px high you could do
或者,如果您的徽标高 60 像素,您可以这样做
body {
padding:60px 0 0 0:
background-image : url(path_to_logo) no-repeat top left;
}
Adding the logo to every body tag (common to every page
将 logo 添加到每个 body 标签(每个页面都有
Ideally you would have a header.php file which you include in every page - by using
理想情况下,您将拥有一个 header.php 文件,该文件包含在每个页面中 - 通过使用
include('header.php');
Then any changes you make to this file will take effect throughout your site, such as adding
然后,您对此文件所做的任何更改都将在您的整个站点中生效,例如添加
<h1>Site title</h1>
<img src="logo.jpg">
回答by Dave
just make a header include and include it on the top of every page?
只是制作一个标题包含并将其包含在每个页面的顶部?
回答by Neil Masters
Add
添加
<div class="logo"> </div>
in your header.
在你的标题中。
Add this to your stylesheet:
将此添加到您的样式表中:
.logo { width: Zpx; height: Ypx; background-image: (pathtoimage.gif); }
Specifying your width and height diameters of course :)
当然指定您的宽度和高度直径:)

