I am trying to implement a grid like layout of images with their corresponding title absolutely positioned relative to that image.
usually when the parent is positioned relatively, the child position absolute works perfectly. Not in this case :(( No matter what I've tried I cannot get this to work.
Sorry had to delete the code as images no longer available.
Michaels solution worked.
Your .hero div has an effective height of 0. Give this element a height and your absolute positioning will work as expected.
Related
I have a table with some data but I want to use one cell for displaying more divs. Each of divs has different exact width and position from the left.
I tried it with position:relative but position of each next div depends on the divs on the left and I don't want that I want each div in that cell to be exactly x pixels from left of the cell border.
I also tried position:absolute but this does go really to the <html> tag as they write here http://www.w3schools.com/css/css_positioning.asp:
An absolute position element is positioned relative to the first
parent element that has a position other than static. If no such
element is found, the containing block is <html>
Now I'm not sure how to solve my problem.
My example: http://jsfiddle.net/6wSAJ/465/
(Made from accepted answer from here: Relative positioning of two divs)
Edit: I guess I forgot to mention that I need it to work in IE8.
Edit 2: http://jsfiddle.net/6wSAJ/468/ The problem I was dealing with is that if I set the cell relative it completely ruins my real problem table so I have to make divs with relative position around the divs I want to be positioned absolutely. I didn't do that at first cause I always want to try to style the elements I have and add new ones only if really necessary.
You should make the wrapping divs a relative position so the absolute position will apply on inner elements:
position: relative;
jsFiddle Demo
Note that you can't give a table-cell a relative position for it's not standardized and will work unexpectedly.
For further reading:
position - CSS | MDN
Learn CSS Positioning in Ten Steps
I am building a design and have it pretty much done however an item I have positioned absolutely will not show the overflow in IE7. It works for every browser but IE7.. I'm not supporting ie6. The div/image will not show anything past its parent container in IE7. I've tried a higher z-index, overflow:visible with no success.. The absolute positioned div is in the top nav bar left of the first menu item.. should be obvious
The site is here
thanks for any help or suggestions
To fix it in IE7, do the following:
Remove:
position: relative;
From .navbar-inner
It's a bit redundant to have it on inner, because it's container is already set to a relative position (they are the same size/shape). It will carry the same effect without it on the inner div, and give you the results you're looking for.
Try giving .navbar-inner a higher z-index value than you have given to the absolutely positioned DIV.
I'd reduce your absolutely positioned elements z-index down to something like 100 and make .navbar-inner 101.
Hi, I am trying to position two images next to each other and have one of them overlap the other one in a corner.
I have tried using the z-index property but this does not work unless i set the position property to something like fixed or absolute and this messes up the layout of my site.
I was wondering that although i have an image container with the width and height set, can i possibly cut out a section of the container like a rectangle to let the image sit inside the cut like the image below me.
Is this possible?
Thanks!
position:relative positions the element relative to its normal position, and pretends, for document flow, that the element is still there. See this example:
http://jsfiddle.net/GtJMF/
position: relative;
I can't see how having a position:absolute for this scenario would mess up your site.
Put position:relative on your "Image Container". Put position:absolute; right:0, bottom:0; on your "Cut out part" (assuming it is also in the Image Container). This will give you the exact effect you are looking for.
Positioning is relative to the containing positioned parent. Just a position:relative is enough make an element a "positioning master" that all interior positioning will use for its coordinate system.
position:relative also "enables" z-index, but unlike absolute and fixed it doesn't mess up any of the rest of the layout.
I am really confused with this. Here I've got a div whose position should be fixed after certain scroll. Before position of that div is absolute. I tried it and found that for one of my screens fixing position is really making document less while on other screen it is not.
What I want to know is which of them is a bug? Does fixing position of element decreases document height?
Thanks
If you use a fixed positioning for an element, it is removed from the "normal layout flow". The height of your document is determined by positioning of all the elements in the page and thus, all changes to positioning affect document height.
Fixed and absolute positioning are explained in detail in the CSS Visual formatting model spec: http://www.w3.org/TR/CSS2/visuren.html#absolute-positioning
Regarding absolute positioning (from the spec):
In the absolute positioning model, a box is explicitly offset with
respect to its containing block. It is removed from the normal flow
entirely (it has no impact on later siblings).
Pretty much the same applies for fixed positioning (Ibid.):
Fixed positioning is a subcategory of absolute positioning. The only
difference is that for a fixed positioned box, the containing block is
established by the viewport.
I am trying to absolutely position an element inside a table cell.
The TD has position:relative and the element has position:absolute.
This works great in all browsers except in Firefox where it is positioned relative to an ancestor relative container.
You can see this reproduced in this fiddle: http://jsfiddle.net/ac5CR/1/
Does anyone know if I miss some CSS setting that can fix that in Firefox?
the element is not a block element.
add to the style display:block, you will get the needed behavior.
A possible work around would be to wrap the position:absolute element with another position:relative div. It requires an extra div, which is lame, but will give you the right result.
Example: http://jsfiddle.net/pTJUk/
Note -- this still won't give a completely correct result, as the position:relative div will be relative to the text position in the td -- crazy, right? Giving the cell a vertical-align:top will make it orient to 0,0, but of course this could be at the cost of other formatting your design requires.
It was a very old Firefox bug that have been fixed about 13 years after being reported!
You may refer to the entertaining history here:
https://bugzilla.mozilla.org/show_bug.cgi?id=63895