473,791 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

4 common methods to overlap 2 images in CSS? any more method? (orelse use a program)

It seems like there are only 4 methods to overlap 2 images using CSS?

There are two images, each with its own URL. Using CSS, there seems to
be 2 ways to overlap them (the task is actually to put a "play button"
image with size 50 x 50 on top of the bigger image which is a video
thumbnail size 200 x 150).

1) Use <div><img ><img ></divwith the play button as the second
image and displayed relatively positioned to overlap the first image.
The div better have enough width so that the second img won't wrap to
the next line.

2) use a div that is relatively positioned without modifying the top
and left value. enclose the video thumbnail image inside of it first,
and then enclose the play button image which is absolute positioned
with some top and left value. Now the 2nd image is absolutely
positioned relative to the outer div.

3) and 4) are suggested by someone

3) use negative margin. this is very similar to (1). will try that
as relative positioning have problem on both IE 6 and 7 (pls see post
http://groups.google.com/group/comp....89f1d55?hl=en#
)

4) use an image that has a background. looks like that's very
possible, but somehow is it true that we cannot easily size the 2
images and position them easily. (for example, how do you position
the play button on the video thumbnail?) one easy method might be to
make them the same size, and with the top image have a lot of
transparent area to achieve the top margin and left margin for the top
image.

Or else, use a PHP program or something similar that can do GD or
ImageMagick, and overlap the smaller image onto the other image, and
then return the resulting image as a single image.

Any other method possible? The PHP method probably works the simplest
for HTML and CSS design coz the final image is really a single image,
but it would take up a lot of CPU time on the servers. Thanks very
much for your help!
Aug 22 '08 #1
5 10877

liketofindoutwh y wrote:
It seems like there are only 4 methods to overlap 2 images using CSS?
I never counted, but there are indeed multiple ways, probably several
more than 4.
There are two images, each with its own URL. Using CSS, there seems to
be 2 ways to overlap them (the task is actually to put a "play button"
image with size 50 x 50 on top of the bigger image which is a video
thumbnail size 200 x 150).
Piece of cake, really.
4) use an image that has a background.
This one get my vote. One way to do it:

div {
background: #fff url(img1.png);
color: #000;
width: 200px;
height: 150px;
text-align: center;
}
img {
margin-top: 50px;
}

<div><img src="img2.png" width="50" height="50" alt="Play"></div>
is it true that we cannot easily size the 2
images and position them easily.
You cannot resize a background image, at least not at this time. Make
the containing div the same dimensions as the background image. If the
background isn't the size you need, resize it in a graphics editor first.

Positioning the foreground image is easy peasy.
(for example, how do you position
the play button on the video thumbnail?)
This is a case where absolute positioning might be useful, but you can
do it just as easily without, just using margin on the <imgor even
padding on the containing <div>

--
Berg
Aug 22 '08 #2
On Aug 22, 4:02*pm, Bergamot <berga...@visi. comwrote:
This one get my vote. One way to do it:

div {
* background: #fff url(img1.png);
* color: #000;
* width: 200px;
* height: 150px;
* text-align: center;}

img {
* margin-top: 50px;

}

<div><img src="img2.png" width="50" height="50" alt="Play"></div>
i see... one reason this has problem is that if a link a wrapped
around the final result, IE won't take the whole thing as the link.
the play button is excluded from the link. some more info on
http://groups.google.com/group/comp....89f1d55?hl=en#
Aug 22 '08 #3

liketofindoutwh y wrote:
On Aug 22, 4:02 pm, Bergamot <berga...@visi. comwrote:
>>
<div><img src="img2.png" width="50" height="50" alt="Play"></div>

one reason this has problem is that if a link a wrapped
around the final result, IE won't take the whole thing as the link.
Sure it will, if you apply the right rules. You had the right idea in
your other post (with the span display:block), you just applied them
kind of backwards.

Put the <aelement in there and make it display:block. You might need
to add a couple more rules, but that should make the inline <afill the
parent div.

--
Berg
Aug 23 '08 #4
On Aug 22, 8:02 pm, Bergamot <berga...@visi. comwrote:
liketofindoutwh y wrote:
On Aug 22, 4:02 pm, Bergamot <berga...@visi. comwrote:
<div><img src="img2.png" width="50" height="50" alt="Play"></div>
one reason this has problem is that if a link a wrapped
around the final result, IE won't take the whole thing as the link.

Sure it will, if you apply the right rules. You had the right idea in
your other post (with the span display:block), you just applied them
kind of backwards.

Put the <aelement in there and make it display:block. You might need
to add a couple more rules, but that should make the inline <afill the
parent div.
now, could it be an IE bug, as IE clearly shows the target link on the
status line of IE, but clicking that play button has no effect.

I don't quite see how right now it is backward... and put the <a>
element there? I thought it is already there.... you mean change <a>
to display:block? i thought in reality, <ais not displayed but is
just to indicate a link. i am sorry, do you think you can give an
example?
Aug 24 '08 #5

liketofindoutwh y wrote:
On Aug 22, 8:02 pm, Bergamot <berga...@visi. comwrote:
>liketofindoutw hy wrote:
On Aug 22, 4:02 pm, Bergamot <berga...@visi. comwrote:
><div><img src="img2.png" width="50" height="50" alt="Play"></div>
one reason this has problem is that if a link a wrapped
around the final result, IE won't take the whole thing as the link.

Put the <aelement in there and make it display:block.

now, could it be an IE bug, as IE clearly shows the target link on the
status line of IE, but clicking that play button has no effect.
IE has lots of bugs, among which is how it handles replaced elements
like <img>, and switching elements from inline to block.
i thought in reality, <ais not displayed but is
just to indicate a link.
Not sure what you mean by that. <ais an inline element, so it is
display:inline by default.
http://www.w3.org/TR/CSS21/visuren.html#display-prop

There is a lot more info on that page about inline and block elements,
among other things.
i am sorry, do you think you can give an
example?
Didn't somebody else already give you a working solution?

--
Berg
Aug 26 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
5926
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
0
2353
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and Methods Version: $Revision: 1.34 $ Last-Modified: $Date: 2004/09/03 09:32:50 $ Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter
8
3354
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city city_id 1 john newyork null
9
1366
by: Mike Meyer | last post by:
Another thread pointed out a couple of methods that would be nice to have on Python collections: find and inject. These are taken from <URL: http://martinfowler.com/bliki/CollectionClosureMethod.html >. find can be defined as: def find(self, test = None): for item in self: if test: if test(item):
23
7043
by: George | last post by:
Is there a way to customize the open file common dialog? I am trying to modify the button text so I can create a delete file common dialog. I need the same functionality of the open file common dialog but just need to change the button text from "open" to "delete". Any ideas? Thanks
7
2235
by: Byron | last post by:
I have several user controls that have a few methods in common, such LoadFromForm() which populates an object from controls on the form. I want to call that method from the form in which the control is contained regardless of the type currently displayed without having to use a huge switch somthing like: switch(curentUserType.GetType()) { case "Person": ((person)currentUserControl).LoadFromForm();
5
3199
by: wrecker | last post by:
Hi all, I have a few common methods that I need to use at different points in my web application. I'm wondering where the best place would be to put these? I think that I have three options. 1. I can create a common module like common.vb in my project and put all the functions in there. 2. Create a utility class and create the common functions as shared
8
4697
by: Arno R | last post by:
Hi all. When I need to search for pictures, I always have too choose thumbnail-view manually. Is it possible to open the common dialog in thumbnail-view programmatically? Example ?? At the moment I am using Ken Getz' code. at http://www.mvps.org/access/api/api0001.htm Thanks Arno R
4
4333
by: Christopera | last post by:
Hello, I have built a site that uses two divs, one verticle, and one horizontal as graphic style for the ite. The problem I am having is that if the browser is resized very small the divs are then smaller than the website is wide. I have tried fixed positioning but then i get the dreaded overlap when the browser is smaller than the website. Absolute positioning gets rid of the overlap but then brings on the width issue. Is there a way to...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.