Fixed element inside draggable fixed element

Ayoze

I have a draggable fixed element and I would like keep inside it another fixed element with position transition effect from right to left. I tried calculate the left and top position with JS but I had problems with the transition. How could I keep this element (orange menu) inside the draggable div (blue) and show and hide(partially)?

$('#fixed-draggable-div').draggable();
#fixed-draggable-div {
  position: fixed;
  top: 50px;
  left: 35%;
  width: 200px;
  height: 300px;
  background: CornflowerBlue;
  overflow-y: scroll;
  padding: 0.5em 1em;
}

#fixed-menu {
  width: 100px;
  background: DarkOrange;
  position: fixed;
  right: -90px;
  top: 40%;
  transition: 1s right;
}

#fixed-menu:hover {
  right: 0;
  transition: 1s right;
}
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
</head>
<body>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum semper molestie arcu. Donec sem sapien, finibus tempor dapibus ut, bibendum vel nunc. Curabitur nunc nulla, ultrices a dictum sed, mattis a risus. Praesent malesuada auctor nisl et sollicitudin. Nunc turpis erat, commodo et lorem consequat, egestas sollicitudin nibh. Aliquam rutrum sapien varius consequat sodales. Vestibulum at tempor mi.</p>

  <p>Pellentesque blandit arcu metus, id imperdiet urna luctus id. Sed ipsum magna, sodales quis mauris eu, sollicitudin tempus diam. Integer tristique est sit amet orci maximus lobortis. Nam porttitor ultrices bibendum. Vestibulum blandit lacinia faucibus. Morbi nulla sapien, maximus at ex tempor, consectetur aliquam sem. Sed feugiat rutrum est ac porttitor. Aliquam gravida, diam nec rhoncus vehicula, velit justo porta sapien, eget fringilla libero justo vel velit. Duis ultrices rutrum gravida.</p>

  <p>Cras quis pharetra turpis. Integer sit amet nunc aliquam, iaculis diam quis, vestibulum enim. Praesent a pulvinar lacus. Nunc in mauris sed tortor consequat volutpat fermentum sed nisl. Cras aliquam lectus mauris, nec ultricies tellus tincidunt vel. Fusce dictum in enim vel sollicitudin. Nam imperdiet molestie dignissim. Suspendisse eleifend maximus orci, eget fringilla enim volutpat et. Quisque erat erat, mollis in tellus ac, rhoncus condimentum ipsum.</p>
  
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum semper molestie arcu. Donec sem sapien, finibus tempor dapibus ut, bibendum vel nunc. Curabitur nunc nulla, ultrices a dictum sed, mattis a risus. Praesent malesuada auctor nisl et sollicitudin. Nunc turpis erat, commodo et lorem consequat, egestas sollicitudin nibh. Aliquam rutrum sapien varius consequat sodales. Vestibulum at tempor mi.</p>

  <p>Pellentesque blandit arcu metus, id imperdiet urna luctus id. Sed ipsum magna, sodales quis mauris eu, sollicitudin tempus diam. Integer tristique est sit amet orci maximus lobortis. Nam porttitor ultrices bibendum. Vestibulum blandit lacinia faucibus. Morbi nulla sapien, maximus at ex tempor, consectetur aliquam sem. Sed feugiat rutrum est ac porttitor. Aliquam gravida, diam nec rhoncus vehicula, velit justo porta sapien, eget fringilla libero justo vel velit. Duis ultrices rutrum gravida.</p>

  <p>Cras quis pharetra turpis. Integer sit amet nunc aliquam, iaculis diam quis, vestibulum enim. Praesent a pulvinar lacus. Nunc in mauris sed tortor consequat volutpat fermentum sed nisl. Cras aliquam lectus mauris, nec ultricies tellus tincidunt vel. Fusce dictum in enim vel sollicitudin. Nam imperdiet molestie dignissim. Suspendisse eleifend maximus orci, eget fringilla enim volutpat et. Quisque erat erat, mollis in tellus ac, rhoncus condimentum ipsum.</p>
  
  <div id="fixed-draggable-div">
    <h3>Draggable element</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum semper molestie arcu. Donec sem sapien, finibus tempor dapibus ut, bibendum vel nunc. Curabitur nunc nulla, ultrices a dictum sed, mattis a risus. Praesent malesuada auctor nisl et sollicitudin. Nunc turpis erat, commodo et lorem consequat, egestas sollicitudin nibh. Aliquam rutrum sapien varius consequat sodales. Vestibulum at tempor mi.</p>
  <p>Pellentesque blandit arcu metus, id imperdiet urna luctus id. Sed ipsum magna, sodales quis mauris eu, sollicitudin tempus diam. Integer tristique est sit amet orci maximus lobortis. Nam porttitor ultrices bibendum. Vestibulum blandit lacinia faucibus. Morbi nulla sapien, maximus at ex tempor, consectetur aliquam sem. Sed feugiat rutrum est ac porttitor. Aliquam gravida, diam nec rhoncus vehicula, velit justo porta sapien, eget fringilla libero justo vel velit. Duis ultrices rutrum gravida.</p>
    <ul id="fixed-menu">
      <li>Element 1</li>
      <li>Element 1</li>
      <li>Element 1</li>
    </ul>
  </div>
  
</body>  
</html>

http://jsfiddle.net/6pwn3wyp/

Ramiz Wachtler

This may solve your problem, but you have to change the offset value. I change the offset to top at scrolling event of your fixed element. Further - you have to change the positionof your #fixed-menuto absolute. Fixed option applies to the whole window.

CSS -

#fixed-menu {
  width: 100px;
  background: DarkOrange;
  position: absolute; //this line
  right: -90px;
  top: 40%;
  transition: 1s right;
}

JQuery -

$('#fixed-draggable-div').scroll(function(){
   $('#fixed-menu').css(
      'top', $('#fixed-draggable-div').scrollTop()+100);
});

Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

fixed position of an element inside a container element

From Dev

Fixed position element inside absolute position element

From Dev

Fixed position element inside absolute position element

From Dev

Jquery UI draggable element from fixed div hidden by absolute element

From Dev

Display scrollbar inside a fixed position element

From Dev

Fixed element below fixed element without JS

From Dev

Position a fixed element below another fixed element

From Dev

draggable inside Canvas element

From Dev

Draggable element inside another draggable element

From Dev

Stick Element to Bottom of Fixed Element

From Dev

Absolute element on top of fixed element?

From Dev

scrolling an element on top of a fixed element

From Dev

Absolute element on top of fixed element?

From Dev

Fixed element in android?

From Dev

Fixed padding in contenteditable element

From Dev

Setting height of fixed element

From Dev

CSS fixed element in section

From Dev

How to fixed a element in Bootstrap?

From Dev

Avoiding overlapping with fixed element

From Dev

Using scrollTop inside of a fixed element with overflow-y:scroll

From Dev

z-index not working inside position fixed element

From Dev

z-index not working inside position fixed element

From Dev

Pin element like position: fixed but inside its parent not the viewport

From Dev

Bootstrap: Element with position fixed inside modal not aligned with respect to the viewport

From Dev

Not draggable element inside Draggable one went wrong

From Dev

two DIVS, one fluid, one fixed, fixed div regardless of height has vertically centered element inside

From Dev

How make a fixed element be on top of another position fixed element

From Dev

Position fixed element within fixed element relative to page

From Dev

Fixed element gets pushed down

Related Related

  1. 1

    fixed position of an element inside a container element

  2. 2

    Fixed position element inside absolute position element

  3. 3

    Fixed position element inside absolute position element

  4. 4

    Jquery UI draggable element from fixed div hidden by absolute element

  5. 5

    Display scrollbar inside a fixed position element

  6. 6

    Fixed element below fixed element without JS

  7. 7

    Position a fixed element below another fixed element

  8. 8

    draggable inside Canvas element

  9. 9

    Draggable element inside another draggable element

  10. 10

    Stick Element to Bottom of Fixed Element

  11. 11

    Absolute element on top of fixed element?

  12. 12

    scrolling an element on top of a fixed element

  13. 13

    Absolute element on top of fixed element?

  14. 14

    Fixed element in android?

  15. 15

    Fixed padding in contenteditable element

  16. 16

    Setting height of fixed element

  17. 17

    CSS fixed element in section

  18. 18

    How to fixed a element in Bootstrap?

  19. 19

    Avoiding overlapping with fixed element

  20. 20

    Using scrollTop inside of a fixed element with overflow-y:scroll

  21. 21

    z-index not working inside position fixed element

  22. 22

    z-index not working inside position fixed element

  23. 23

    Pin element like position: fixed but inside its parent not the viewport

  24. 24

    Bootstrap: Element with position fixed inside modal not aligned with respect to the viewport

  25. 25

    Not draggable element inside Draggable one went wrong

  26. 26

    two DIVS, one fluid, one fixed, fixed div regardless of height has vertically centered element inside

  27. 27

    How make a fixed element be on top of another position fixed element

  28. 28

    Position fixed element within fixed element relative to page

  29. 29

    Fixed element gets pushed down

HotTag

Archive