html - how to position logo half way over div below it no matter what screen size -


i need position logo half way on div below in image below , cannot seem perfect. needs halfway on not matter screen size or browser size, during adjusting of browser size.

i using positioning this

.site-icon {   width: 15%;   top: 6%;   right: 11.9%; } 

html section

<div class="container-fluid page-container-2">   <h1 class="page-title-2 small-header">    <a href="/">site title</a>   </h1>    <!-- icon -->   <a href="/"><img class="site-icon" src="/resources/img/icon.png" alt="site_title"/></a>    <!-- div holding banner image -->   <div class="col-xs-12 banner-image-container-2 no-pad" style="background: url({% resource banner_image['path'] %}) no-repeat center center;background-size:cover;"></div>  .... rest of page .... 

but fails when browser shrunk down vertically or horizontally , cannot figure out how achieve css.

any appreciated.

enter image description here

well, when wrote answer, didn't have html code in question ,so came own - should understandable answer question... (won't change anymore now)

the important thing have combination of position: relative (for parent) , `position absoute (for child element), plus width, height , position settings child. take @ settings in snippet below.

.x {    position: relative;    top: 70px;    height: 160px;    background: #fa0;  }    .site-icon {    position: absolute;    width: 15%;    height: 50%;    top: 0;    right: 12%;    transform: translatey(-50%);    background: #0fa;  }
<div class="x">    <div class="site-icon"></div>  </div>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -