so as the title says i need to float my div with absolute position to the left while keeping left: 100px
or whatever it's set to, for example let's say i have these rules:
.myDiv{
position:absolute;
left:100px;
top:100px;
width:50px;
height:50px;
}
Now how can i float
it to the left side which would be left:0px
without using this left
command, i need something similar to float:left
also javascript
is totaly acceptable.
And if any one is wondering why i need this quite strange thing is because i want to keep this object offset so later i could bring it back to it's original position.
You cannot do this. Absolutely positioned objects can only be moved by changing one or more of left
, top
, bottom
, right
(or relocating them inside the DOM tree).
If you want to be able to move the element to a previous position, save the value of left
somewhere so that you can restore it when the time comes. It's easy to do and will be by itself enough to accomplish almost anything you will want it to.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.