Here's the code example I'm having problems with:
http://jsfiddle.net/eejpjch3/
I'm trying to add a dynamic delete button above HTML elements when hovering. For instance when I have the following HTML:
<div class="row-fluid" object="columns-editable">
<div class="col-md-6" object="column-editable">Column 1</div>
<div class="col-md-6" object="column-editable">Column 2</div>
</div>
<div class="row-fluid" object="columns-editable">
<div class="col-md-6" object="column-editable">Column 1</div>
<div class="col-md-6" object="column-editable">Column 2</div>
</div>
For each row, when the user hovers, an icon pops up above that row which allows them to delete the row. However, when I'm doing this in the code, the position of the delete button stays positioned at the top of the first row even though it's set to an absolute position.
Thank you for your help.
An absolutely positioned element is an element whose computed position value is absolute or fixed . The top , right , bottom , and left properties specify offsets from the edges of the element's containing block. (The containing block is the ancestor relative to which the element is positioned.)
Absolutely positioned elements are positioned with respect to a containing block, which is the nearest postioned ancestor. If there is no positioned ancestor, the viewport will be the containing block. Elements with fixed positioning are fixed with respect to the viewport—the viewport is always their containing block.
Fixed Positioning You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document. Move Left - Use a negative value for left. Move Right - Use a positive value for left. Move Up - Use a negative value for top.
Absolute positioning works based on the first parent it has with a relative positioning. Since you have no items with relative positioning it'll be the window that is relative. Adding
.row-fluid { position: relative; }
Would achieve what you want
Why not use relative
positioning? Here is your example using some alternative style rules, specifically
.icon {
float:right;
position: relative;
bottom: 15px;
}
.upper-controls {
position: relative;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With