473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CSS Float Positioning Question

Here is the functional part of my problem

Expand|Select|Wrap|Line Numbers
  1.     <a onmouseover="document.getElementById('PopUp').style.display = 'block';"><img src="http://www.garthbigelow.com/images/Marchsep.gif"></a>
  2.     <div id='PopUp' style='display: none; position: absolute; border: solid black 1px; padding: 10px; 
  3.                            background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 235px;'
  4.          onfocus='this.blur();'
  5.          onmouseout= "document.getElementById('PopUp').style.display = 'none' ">
  6.     This is a CSS Popup that can be positioned anywhere you want on the page and can contain any test and images you want.
  7.     </div>

Yes, this does what I want. It creates a float which appears when the mouse points to the image and disappears when the mouse leaves the float.
What I can't get, is that I want the float to be positioned so that the top left corner of the float is the same as the top left corner of image.

I've played with this for hours, but I just barely understand what I've already done, let alone what I'm trying to do.

Thanks
Garth
Mar 21 '07 #1
10 2734
AricC
1,892 Expert 1GB
Here is the functional part of my problem

Expand|Select|Wrap|Line Numbers
  1.     <a onmouseover="document.getElementById('PopUp').style.display = 'block';"><img src="http://www.garthbigelow.com/images/Marchsep.gif"></a>
  2.     <div id='PopUp' style='display: none; position: absolute; border: solid black 1px; padding: 10px; 
  3.                            background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 235px;'
  4.          onfocus='this.blur();'
  5.          onmouseout= "document.getElementById('PopUp').style.display = 'none' ">
  6.     This is a CSS Popup that can be positioned anywhere you want on the page and can contain any test and images you want.
  7.     </div>

Yes, this does what I want. It creates a float which appears when the mouse points to the image and disappears when the mouse leaves the float.
What I can't get, is that I want the float to be positioned so that the top left corner of the float is the same as the top left corner of image.

I've played with this for hours, but I just barely understand what I've already done, let alone what I'm trying to do.

Thanks
Garth
You got a link to the page? So it's popping up just not where you want it too?

Aric
Mar 21 '07 #2
drhowarddrfine
7,435 Expert 4TB
Because the image occupies that space as part of the normal flow. To remove it from the normal flow, you can float the image left.

For fun, float the image left but remove position:absolute from the div and see if you like it.
Mar 21 '07 #3
You got a link to the page? So it's popping up just not where you want it too?

Aric
I've been testing it locally, really didn't post it anywhere but I can if that's important.
Yes, it's just not popping up where I want it. I can position it in absolute terms, but I didn't do that in the example, because what I want to do is position it so that the upper top left corner is the same as that of the image.
Mar 21 '07 #4
Because the image occupies that space as part of the normal flow. To remove it from the normal flow, you can float the image left.

For fun, float the image left but remove position:absolute from the div and see if you like it.
removed 'position:absolute' added 'float:left'. It caused no noticeable change in the action of the code.
Mar 21 '07 #5
Because the image occupies that space as part of the normal flow. To remove it from the normal flow, you can float the image left.

For fun, float the image left but remove position:absolute from the div and see if you like it.
Ah, just understood what you were saying, but the centering of the picture is important to the final product.
Mar 21 '07 #6
drhowarddrfine
7,435 Expert 4TB
So what did you do? I assume the "for fun" solution was not what you want so did the first one work? If not, what doctype are you using and which browser?
Mar 22 '07 #7
So what did you do? I assume the "for fun" solution was not what you want so did the first one work? If not, what doctype are you using and which browser?
Let me try this again. I've been trying to figure this out in the interim so the code has changed some as I keep trying to remove elements.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <title>float test</title>
  6. </head>
  7. <body>
  8.  
  9.     <p align="center">
  10.     <img src="images/Marchsep.gif" onmouseover="document.getElementById('PopUp').style.display = 'block'; 
  11.                                                 document.getElementById('PopUp').style.top = this.top;
  12.                                                 document.getElementById('PopUp').style.left = this.left;">
  13.     <div id='PopUp' style='float: none; display: none; position: absolute; top: 0; left:0; border: solid black 1px; padding: 10px; 
  14.                            background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 235px;'
  15.          onmouseout= "this.style.display = 'none' ">
  16.     This is a CSS Popup. I would like it to be positioned so that the top left of the pop up is based on the top left of the IMG.
  17.     </div></p>
  18.  
  19. </body>
  20.  
  21. </html>
  22.  
This code produces an error, I suspect that this because img.left and/or img.top are probably not legal elements.
This should hopefully be enough to inform on what I am trying to do, and hopefully a solution will be provided.

Thank you for your time on this so far.
Garth
Mar 22 '07 #8
AricC
1,892 Expert 1GB
what doctype are you using and which browser?
I don't see a doc type in your code.
Mar 22 '07 #9
drhowarddrfine
7,435 Expert 4TB
You need a doctype. See the sticky at the top of this board.
Change this to utf-8:
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
************************************************** ***************
align is deprecated. Use css instead
<p align="center">
************************************************** **************
There is no "float:none" document.getElementById('PopUp').style.left = this.left;">
<div id='PopUp' style='float: none; display: none; position: absolute; top: 0; left:0; border: solid black 1px; padding: 10px;
background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 235px;'
Mar 22 '07 #10
drhowarddrfine
7,435 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4.   <head>
  5.     <title></title>
  6.     <meta http-equiv="content-type" content="text/html;charset=utf-8" >
  7.     <style type="text/css">
  8.  
  9.     </style>
  10.   </head>
  11. <body>
  12. <p>
  13. <a onmouseover="document.getElementById('PopUp').style.display = 'block';">
  14.     <img src="http://www.garthbigelow.com/images/Marchsep.gif" style="float:left">
  15. </a>
  16. </p>
  17. <div id='PopUp' style='display: none; position:absolute; border: solid black 1px; padding: 10px; 
  18.                       background-color: rgb(255,255,225); text-align: justify; font-size: 12px; 
  19.                       width: 235px;'
  20.  
  21.                      onmouseout= "document.getElementById('PopUp').style.display = 'none' ">
  22.     This is a CSS Popup that can be positioned anywhere you want on the page 
  23.     and can contain any test and images you want.
  24. </div>
  25.  
  26. </body>
  27. </html>
Mar 22 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Aaron | last post by:
I'm using relative positioning to move a right-floated image 10px upwards.. Text wrapping around the image should go underneath it once it reaches the bottom of the image, yet it acts as if the...
1
by: JKenyon | last post by:
I am attempting to display two images on a web page. The second "image" is actually two images, one overlaid on the other. The first one is aligned on the left using float:left. I have enclosed...
2
by: Penguinny | last post by:
Dear all, I am trying to make a relatively simple layout with two adjustment columns filled with short news pieces, but there's a catch. I cannot control the html for these news bits, so I am...
2
by: Dr. Richard E. Hawkins | last post by:
I've googled around, and asked everyone I know, but I still can't find any reference to anyone else having faced this particular IE bug with floats. I've put a page at...
16
by: Wolfgang Meier | last post by:
Hi, Although it might seem like I am firing out random posts in quick succession this matter is indeed one I thought about for quite some time without coming to a conclusion: Why is it that...
34
by: Xah Lee | last post by:
i have a very simple html doc using the following style: <style type="text/css"> ..x-note {background-color:#afeeee; margin:1ex; padding:1ex; float:right; line-height:130%; width:60ex;...
14
by: Mark | last post by:
please view http://mnbayazit.com/misc/sample.gif i'm wondering how i can make the sidebar (green) float to the right of the main text, without specifying the width of the main content (because...
3
by: hantechs | last post by:
<html> <body> <p style="width:30%;">text1</p> <p style="float:left;">text2</p> </body> </html> The effect of this html code is : text1 and text2 each is on a line. My question is: Why text2...
1
by: TopherB | last post by:
It came to me while sleeping that my question was not being answered (all answered where in the form of changing the question) because the answer was not readily available. So I thought I might ask...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.