[英]Hide text in H1 tag but not the image
I need to hide the text inside a H1 tag. 我需要隐藏H1标签内的文本。 But not the image.
但不是形象。 Problem is that i only can change the css and not the html
问题是我只能改变CSS而不是html
<h1>
<img src="img/headerimg.png" width="900" height="125"/>
Header 1 text
</h1>
Is there a way to only hide the "Header 1 text" with only css? 有没有办法只用css隐藏“标题1文本”? I'm doing this for big client and they gave me only acces to the css file.
我正在为大客户端做这个,他们只给我访问css文件。
Set the image as background of the <h1>
, add CSS properties to the <h1>
to make it the size of the image and use a negative text-indent
on the headline to remove the text. 将图像设置为
<h1>
背景,将CSS属性添加到<h1>
以使其成为图像的大小,并在标题上使用负text-indent
来删除文本。 That would be the usual and ideal way to do it if you had access to the html too. 如果您也可以访问html,这将是通常和理想的方式。
Since you only have access to the CSS, you can use this: 由于您只能访问CSS,因此您可以使用:
h1 {
font-size: 0.1px; /* 0 gets disregarded by Internet Explorer, 0.1 gets interpreted right by every browser */
}
Fiddle: http://jsfiddle.net/VGgnD/ 小提琴: http : //jsfiddle.net/VGgnD/
<h1>
<img src="img/headerimg.png" width="900" height="125"/>
Header 1 text
</h1>
h1 {
width: 900px;
height: 125px;
background: url("img/headerimg.png") no-repeat center center;
text-indent: -99em;
}
If you have access only to CSS, please display: none;
如果您只能访问CSS,请
display: none;
the img
: img
:
h1 img {display: none;}
Well the only thing that comes to my mind is this: 那么我唯一想到的就是:
<h1 style="color: transparent; font-size: 0px; text-indent: -99em;">
<img src="http://pokit.org/get/img/18d5148ef77ef2a2d5d8193c1c8789e8.jpg" width="900" height="125"/>
Header 1 text
</h1>
Working example: 工作范例:
set font-size: 1px !important;
set
font-size: 1px !important;
and set background color as text color 并将背景颜色设置为文本颜色
It could be as simple as setting the font-size to 0px 它可以像将font-size设置为0px一样简单
h1 {
font-size: 0.1px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.