css - Responsively moving text inside of a div -


my question quite simple i've been struggling quite time.

https://jsfiddle.net/txzk0ffm/

body {    width:100%;  }  h1{    margin:0;  }  .box-wrap {    width:70%;    background:red;    height:350px;  }  .text-wrap {    width:35%;    position:relative;    top:25%;    background:rgba(0,0,0,.5);  }
<div class="box-wrap"style="background:red url(http://www.saadiyat.ae/admin/content/banner-img-3.jpg) 50% 50% no-repeat;">    <div class="img-wrap" >      <div class="text-wrap">        <h1>          random text        </h1>      </div>    </div>  </div>

how move box text use of % using things

top:50%; bottom:30%; etc. 

i tried use position relative, nothing seems happening

parent height auto, can't use percentage vertical mesurment inside of it.

you need add

.img-wrap {   height: 100%; } 

to solve problem:

h1{    margin:0;  }  .box-wrap {    width:70%;    background:red;    height:350px;  }  .text-wrap {    width:35%;    position:relative;    top:25%;    background:rgba(0,0,0,.5);  }    .img-wrap {    height: 100%;  }
<div class="box-wrap"style="background:red url(http://www.saadiyat.ae/admin/content/banner-img-3.jpg) 50% 50% no-repeat;">    <div class="img-wrap" >      <div class="text-wrap">        <h1>          random text        </h1>      </div>    </div>  </div>


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -