简体   繁体   English

在图像上放置文字

[英]Put a text over an image

How it is possible to place only a part of the text over an image in html? 如何将仅文本的一部分放在html图像中? Considering the following example: http://jsfiddle.net/EgLKV/3/ 考虑以下示例: http : //jsfiddle.net/EgLKV/3/

I would like to reach that the "Hello" word is outside the image on the left side. 我想知道“ Hello”一词在左侧图片的外面。 And the "World" word is within the image. 图像中包含“世界”一词。 I added -50px to the left attribute which gave me the desired result. 我将-50px添加到left属性,这给了我想要的结果。

 #text{
   z-index:100;
   position:absolute;    
   color:white;
   font-size:24px;
   font-weight:bold;
   left:-50px;
   top:350px;
}

My question is if this a good idea to reach this result. 我的问题是,达到这个结果是否是个好主意。 Or would it be better to make a second outer container holding the "Hello" word? 还是制作第二个包含“ Hello”字样的外部容器会更好? Any suggestions? 有什么建议么? Thank you 谢谢

I think it depends on what you plan to do with the space to the left. 我认为这取决于您打算如何处理左侧的空间。 Adding an outer container could cause additional problems if you need to use that space, but if it's going to be empty I don't think it really makes much of a difference. 如果您需要使用外部容器,则添加外部容器可能会导致其他问题,但是如果该容器将是空的,那么我认为这并没有太大的区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM