简体   繁体   English

带有字幕叠加的CSS Box,最佳做法?

[英]CSS Box with caption overlay, best practice?

This is some html and css, you can see what it does:_ (The first box is really the one that matters) 这是一些html和css,你可以看到它的作用:_(第一个框真的是重要的一个)

http://jsfiddle.net/rcGsH/2/ http://jsfiddle.net/rcGsH/2/

The problem is to make this work properly with the image there, I have to use some tricks to get it to work properly that don't seem very good... like 问题是使这个工作与那里的图像正常工作,我必须使用一些技巧,让它正常工作,似乎不是很好......就像

floating the img left or right so it's not really taking up space.. (is there another way around this? or is it fine how i'm doing it?) 向左或向右漂浮img所以它并没有真正占用空间..(还有另外一种方法吗?或者我是怎么做的?)

.ad img {
height: 175px; width: 175px;
float: left;
}

And making another wrapper div around the text inside the ad_info div and setting it to bottom: 175px so that the text stays in the transparent part... is there another way to this as well? 并在ad_info div中的文本周围创建另一个包装器div并将其设置为bottom:175px以便文本保留在透明部分中......还有另一种方法吗?

If anyone has proper fixes to these problems or these are fine please tell... 如果有人对这些问题有适当的解决方法,或者这些都没问题,请告诉...

OR I have another idea where i could put the image as a background image with JQuery, (since the image will come from php), i have a good idea of how that would work but could anyone tell me which solution is better? 或者我有另一个想法,我可以将图像作为背景图像与JQuery,(因为图像将来自PHP),我很清楚这将如何工作,但谁能告诉我哪个解决方案更好?

Thanks! 谢谢!

There is a lot of ways to do this, you are doing right (maybe some extra divs), but I thinks this is what you are looking for: 有很多方法可以做到这一点,你做得对(也许是一些额外的div),但我认为这是你正在寻找的:
Boxes, images and captions 框,图像和标题
Like an extra, they use a little bit jquery, to animate the boxes ;) 像一个额外的,他们使用一点点jquery,动画框;)

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

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