html - Div on Div displaced -


enter image description here

i'm trying write div on div , i'm stuck trying title right on line of div. know how this?

you may interested in looking position of en element.

for example, using middle box 'middle' div, , displaced div title;

.outer {    margin: 0 auto;    height: 400px;    width: 80%;    border: 5px solid red;    position: relative;  }  .middle {    height: 200px;    width: 80%;    border: 5px solid blue;        /*centering blue div middle of red box*/    position: absolute;    top: 50%;    left: 50%;    transform: translate(-50%, -50%);  }  .displaced {    font-size: 30px;        /*needed put green div onto line*/    position: absolute;    left:50%;    transform: translate(-50%, -50%);    border: 2px solid green;  }
<div class="outer">    <div class="middle">      <div class="displaced">        on line      </div>    </div>  </div>


for more information please read w3c documents relating positioning.

further reading

  • the transform property, allows use 'translate' child element relation parent has position defined (such relative, or in case, 'middle' div's absolute position)

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -