Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Container to overlap parent container

Tags:

html

css

I have two divs inside of eachother. The one #outside has a 5px border and the second #inside has content in it. I want #inside to overlap #outside at the top and bottom so that it effectively breaks the border and appears to be 2 brackets, if that makes sense.

HTML

 <div id='outside'>
      <div id='inside'>
           <h1>Sample header</h1>
           <p>Sample copy</p>
      </div> <!-- inside -->
 </div> <!-- outside -->

CSS

 #outside {
      border: 5px solid #000;
      padding: 5px;
 }

I dont quite know how to move the #inside div over the outside div, any advice will help!

like image 202
mauzilla Avatar asked Mar 12 '26 05:03

mauzilla


2 Answers

Now you can used to position for this design

as like this

#outside {
      border: 5px solid #000;
      padding: 5px;
  position:relative;
 }

#inside{
background:red;
  position:absolute;
  top:-10px;
    left:10px;
  right:10px;
}

Demo1

DEMO2

like image 111
Rohit Azad Malik Avatar answered Mar 14 '26 22:03

Rohit Azad Malik


Add negative margins to inside..

Concept:

#inside {
    width:   110%;
    height:  110%;
    margin-top: -10%;
    margin-left: -10%;
}

Or make outside position: relative; and make inside position: absolute; with a top: -10px; left: -10px;

like image 43
Damien Overeem Avatar answered Mar 14 '26 22:03

Damien Overeem