user1401231 user1401231 - 2 months ago 3x
CSS Question

CSS - Allow an div to stick out of its parent

I've been searching a lot for a way to allow a div to stick out of its parent.

The parent has float:right and I'm trying to make clicking it toggle show/hide a child element, but the child element shows/hides after the div. I'd like to make it "stick out" of the parent div.

Thanks! :)


Your explanation is not very clear, but here is a demo of a right-aligned parent div with a child div that sticks out. I hope that is what you're looking for :)

#parent {
  width: 200px;
  height: 200px;
  background-color: #FF0000;
  float: right;
  position: relative;
#child {
  width: 300px;
  height: 100px;
  background-color: #00FF00;
  position: absolute;
  right: 0;
<div id="parent">
  <div id="child">