Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move absolute div outside the parent

Tags:

css

Is it possible to move an absolute positioned div outside the parent's borders?

I tried (less) left:calc(~'0%-15px') but does not seem to work :)

.dif-links {
    background: pink; width: 25px; height: 100px; 
    position: absolute; text-align: center;
    left:calc(~'0%-15px')
}

I have an article and I would like to maintain the "share" div outisde the article body, this is why I used the absolute position, but now just move it to the left side of parent seems to be complicated...

enter image description here

Here is my pen

like image 733
serge Avatar asked Oct 12 '15 16:10

serge


2 Answers

Assuming the parent is its containing block (e.g. has position: relative), the easiest way is

position: absolute;
right: 100%;

#wrapper {
  position: relative;
  background: yellow;
  margin: 0 50px;
  height: 50px;
}
#inner {
  position: absolute;
  right: 100%;
  border: 2px solid red;
}
<div id="wrapper">
  <div id="inner">Foo</div>
</div>
like image 82
Oriol Avatar answered Sep 20 '22 05:09

Oriol


Just set a margin-left of -25px.

like image 32
Kerim Incedayi Avatar answered Sep 21 '22 05:09

Kerim Incedayi