html - CSS - Position an element in percent from its own width -


i position center of element (regardless of height) on bottom of parent. thought i'd go absolute nothing makes sense. see picture below :

enter image description here

<div id="red">     <div id="blue"></div> </div> 

how can have result ?

edit : @gaby aka g. petrioli found solution :

#red{    width: 300px;    height: 200px;    background: red;    position:relative;  }  #blue{    width: 100px;    height: 50px;    background: blue;    right:3%;        /* here magic solution*/    position:absolute;    bottom: 0;    transform: translatey(50%);  }
<div id="red">          <div id="blue"></div>      </div>

you should use absolute position place @ bottom, , use transform translate move 50% upward since work in regard own height.

so

.red{position:relative} .blue{    position:absolute;    top:100%;    right:50px;    transform:translatey(-50%); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -