I am positioning points on a map through divs.
I have the following code:
<div id="map" style = "background-image:url('map.gif');width:382px;height:524px;">
<DIV STYLE="position:absolute; top:222px; left:204px;">
<img src="bullet.gif" border=0>Point
</DIV>
</DIV>
When I add this code on my page, the point is not on the map so I added a position:relative
<div id="map" style = "background-image:url('map.gif');width:382px;height:524px;position:relative;">
Now the point is on the map but its a bit off from where I initially wanted. Does anyways have a fix for this? Also The points are in different positions in different browsers. Is there a way to standardize where the position is?
I recommend only using one level (instead of cascading), also, spans for the overlay.
<div>
<div>
</div>
<div>
use
<div style=...> the map
</div>
<span style=...></span> an overlayed rectangle
<span style=...></span> an overlayed rectangle
is this ok for you? If not pleas specify and i will adapt it.
well you may need to adjust the "top" and "left" values, since the "point" is now positioned absolutely relative to the "map" div.
Check this out if it helps http://jsfiddle.net/DK9wT/6/
Related
I'm trying to make multiple nested 3D transformed elements. I.e. several nested elements all have 3D transformations and the transform-style:preserve-3d property.
However, when an element has an overflow property, all of its ancestors are flattened.
For example:
<style>
div{transform-style:preserve-3d;}
</style>
<div style="transform:rotateY(30deg) rotateX(-30deg);">
<div style="transform:translateZ(30px)">
<div style="transform:translateZ(30px)">
<div style="transform:translateZ(30px);overflow:hidden"><!-- everything beyond here is flat -->
<div style="transform:translateZ(30px)">
<div style="transform:translateZ(30px)">
<div style="transform:translateZ(30px)">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Fiddle: http://jsfiddle.net/Lqfy3mgs/
I tested this in Chrome and FF. Is it possible to make the ancestors 3D even with a overflow?
I'm afraid that's per the spec:
The following CSS property values require the user agent to create a
flattened representation of the descendant elements before they can be
applied, and therefore force the used value of transform-style to
flat:
overflow: any value other than visible....
Source: http://dev.w3.org/csswg/css-transforms/#grouping-property-values
w3:
hidden
This value indicates that the content is clipped and that no scrolling user interface should be provided to view the content outside the clipping region.
As you can see this is for 3d transformed elements aswel so even the transform cant escape the clipping that happends when setting overflow:hidden.
I've tried several remedies after searching here but can't seem to make this work.
2 separate divs: 1 div with 4 image links in separate columns (each has a CSS fade rollover effect), and one div underneath with a simple line of text in a full-width column. I'm trying to hide the text div and reveal it upon triangle image rollover.
Here's a link with the images and the first text blurb shown below: http://goodsouldesign.com/redmont
<div id="triangles>
<a>image1</a>
<a>image2</a>
<a>image3</a>
<a>image4</a>
</div>
<div id="blurb1>Text here</div>
<div id="blurb2>Text here</div>
<div id="blurb3>Text here</div>
<div id="blurb4>Text here</div>
Any ideas are appreciated!
Now that I know exactly how you have it laid out, I'm writing a new answer. While you may need the blurbs to span the full width, they are still very close to the elements, which means they could be made into siblings. Take this for example:
<div id="wrapper">
<a id="tri1"></a>
<a id="tri2"></a>
<a id="tri3"></a>
<a id="tri4"></a>
<div id="blurbs">
<div id="blurb1">Text here 1</div>
<div id="blurb2">Text here 2</div>
<div id="blurb3">Text here 3</div>
<div id="blurb4">Text here 4</div>
</div>
</div>
The blurbs are now a child of the blurbs container, which in turn is a sibling of the triangles. This would allow you to use the css sibling selector ~ to access them.
Alternatively, you don't even need the blurbs container.. It might make styling a little easier, but you could accomplish this layout simply by having the blurbs be block elements, whilst the triangles are display: inline-block;. This would put all the triangles on the same line, and bump a blurb down below it. Give it 100% width, and it should be what you want.
Here's a fiddle that shows how to do this with no container, and the sibling selector:
#wrapper #tri1:hover ~ #blurb1 { display: block; }
http://jsfiddle.net/cJJtc/1/
Hope that helps!
UPDATE:
I realized that my answer might have been a bit to quick to dismiss what you were doing.. I assumed that you had the text blurbs in a different area than the triangles which would make this impossible... However, if the text is meant to be right underneath the images or some similar layout, you can move the blurbs to be inside of the triangles wrapper, underneath their corresponding triangle image, and then use an adjacent css selector (exactly like the example you posted in the comments) to hide and show them. Let me know if you need an example.
Pure CSS cannot be used to create an effect such as this. The reason for this is that CSS is sequential, and can only be applied in an inward and onward fashion.. Basically, a CSS selector can only apply to an element, it's siblings which come after it, or it's children. Selecting parent elements, or elements outside of an element's "family" is not something that CSS should be used for.
An effect like this would typically be done with Javascript, which has much more power of selection.
For example:
document.getElementById('tri1').onmouseover=function(){
document.getElementById('blurb1').style.display = "block";
};
document.getElementById('tri1').onmouseout=function(){
document.getElementById('blurb1').style.display = "none";
};
See this fiddle for a full example:
http://jsfiddle.net/tQjd4/
(I'm not expert on javascript, so I'm sure there are more efficient ways to do it, but that works!)
I tend to use jQuery to shortcut my javascript, which would be something like:
$('#triangles a').hover(function(){
$('#'+$(this).attr('rel')).css('display','block');
}, function(){
$('#'+$(this).attr('rel')).css('display','none');
});
assuming that you've given each triangle a rel attr equivalent to the blurb text id
I've been searching for this solution for a while now... [bla bla... google.. bla]...
I have created an example where I'm almost there, but not quite:
http://www.mikael-sandbox.com/puzzlecss/
What I have left here is that I want the number 1 to always be in the lower right corner. This is the case as long as I have ONE single row of blocks, but as the row breaks, the row is moved up. I want it to stay down. Any thoughts?
If the elements are being dynamically added to your page (even if they aren't), it would seem that the obvious solution would be to reverse the order of them. The elements that would extend beyond the bounds of the container are going to always wrap below. Found a couple links that may offer some insight regarding float and wrapping.
http://archivist.incutio.com/viewlist/css-discuss/33948
http://css.maxdesign.com.au/floatutorial/introduction.htm See "Where will a floated element move to?"
Edit
Is your container fixed width, and will your bit divs be consistent width? If so, then you know you can fit X number of bit divs on a row in your container. With that in mind, you would wrap a "row" in a div, and clear it on both sides. The sample below achieves the results I believe you are looking for. I'm fairly certain that you will not be able to achieve this with pure CSS. Floats just don't work the way you want them to.
<div id="container">
<div id="row_wrapper" style="clear:both;">
<div class="bit">10</div>
<div class="bit">11</div>
<div class="bit">12</div>
</div> <!--End row_wrapper -->
<div id="row_wrapper" style="clear:both;">
<div class="bit">1</div>
<div class="bit">2</div>
<div class="bit">3</div>
<div class="bit">4</div>
<div class="bit">5</div>
<div class="bit">6</div>
<div class="bit">7</div>
<div class="bit">8</div>
<div class="bit">9</div>
</div> <!--End row_wrapper -->
</div> <!--End container -->
ok this header image is driving me crazy-- ive cleaned up the divs and edited the css - before i learn positioning etc, id love to see a quick fix that just puts that image down at the bottom of the page
sorry, the question was in the title-- im trying to get the footer not to float on top of the page but ive gotten some responses about absolute positioning so ill try and work on that myself, additional answers still appreciated, thanks
http://we-live.in/the_sierra
<div style="text-align:center;">
<div id="footernav">
Home
About Us
Contact Us
</div>
Your main content div appears to be the div with the id "to_div". Your footer floats to the top because you've used position:absolute on to_div which takes it out of the flow. Either absolutely position your div on the bottom or stop using absolutely positioning. I recommend the latter.
That happens because you have set up to absolute the position of each div (to_text, nav_deals, etc.) but the div that contains the footer is rendered as a normal div element (because its position is not absolute)!
I suggest to redo this simple layout without the absolute positioning! Or you can solve by setting to absolute even the position of the last div!
The problem is that you are using absolutes. Absolutes do not affect the flow (in other words for the positioning of other elements it's as if they don't exist).
Do something like this (I've put the css as text)
<div id="wrapper">
<div id = "main">
<div id="to">FLOAT:LEFT</div>
<div id="from">FLOAT:RIGHT</div>
<p class="extro">CLEAR:BOTH</p>
</div>
<div id="footer"></div>
</div>
I have gone through a long tutorial on W3Schooles to learn CSS; I learnt some basics but still miss my primary aim: Positioning DIVs
This is what I'm trying to do
*---------*---------*
* * *
* * *
*---------*---------*
My goal is simple and trivial for some, but I'm having headaches doing this the right way, in fact I did it but it has lot of problems when I add more text to the DIVs or they simply merge with another DIVs
What I did is simply play with margin and padding values using FireBug. All I need now is to learn me this simple (I hope) trick, what I'm missing is: how this simple positioning works? Shall I use absolute, relative positioning? Change the margin, the padding, the size??
If you have a good tutorial explaining this point, so please point it. I had other headaches looking for that on Google.
It looks like you are trying to float two columns next to each other. This is fairly simple and covered in depth here :
http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/
I tend to stay away from the position property unless I have to overlay some elements.
Creating a 2 column layout in CSS
Personally, I don't like using a clear:both on a br tag.
Use overflow: auto on the parent div instead
<div class="container" style="overflow: auto">
<div style="width:300px;float:left"><p>left column</p></div>
<div style="width:300px;float:left"><p>right column</p></div>
</div>
I've had good luck emulating the code found in the 960 grid system.
The right way is hard because many things aren't really cross browser compatible. Browsers are getting better, but its still a nightmare if you have to use anything IE compatible. (lots of hacks)
With absolute positioning you can absolutely place any of your div's. the drawback being that they are stuck in those positions no matter the resolution or the size of the window displaying your page.
What you could do is float your left column to the left, and then not specify floating on the right column. Keep the default positioning by not specifying absolute nor relative, then just adjust the widths of the elements as needed.
If you are okay with setting specific widths on your divs, the following has worked well for me:
<div style="width: 200px; float: left;"> left column </div>
<div style="width: 600px; float: left;"> right column </div>
<div style="clear: both;"> footer (can be left blank) </div>
The "float: left" makes the columns line up side-by-side. The last div (with the clear: both) makes it so that anything you put after the columns stays below the columns. This way, you can change the width of either column without messing with the styling of the other.
<div class="container">
<div style="width:300px;float:left"><p>left column</p></div>
<div style="width:300px;float:left"><p>right column</p></div>
<br style="clear:both" />
</div>