Function js that assigns height div

0

Friends, someone can help me, I'm stuck on this (I do not handle the subject very much) How to make a function that assigns the height to a div from the height of a daughter image + 10px or%. here my draft see draft I appreciated the help Postscript the position of the image must be absolute (it can not be other)

Code added:

function myFunction() {
   var alto = document.getElementById("pic").style.height;
   }
   //funcion que asigne al id #bigPic la altura de la imagen #pic + 10px o 10% al cargar la pagina 
/* Es decir que el div que contiene la imagen la alura se la de la imagen mas unos pixeles o % de mas */
.color1 { background:red; }
.color2 { background:green; }
#bigPic img {
	width: 80%;
  height:auto;
	top: 10%;
	left: 10%;
	position: absolute;
}
#bigPic {
	background: #F7A3A4;
  width: 90%;
  position:relative;
  }
<div class="container-fluid text-center">

<div class="row">
  <div class="col-xs-6 col-sm-8 color1">
  <div id="bigPic"> <!-- div al que debo asignarle la altura-->
    <img id="pic" src="http://lorempixel.com/200/250/"  alt="" /> <!-- img donde tomo la medida-->
   </div>
  </div>
 <div class="col-xs-6 col-sm-4 color1">.col-md-4</div>
</div>


<div class="row">
  <div class="col-sm-8 color2">.col-md-8</div>
  <div class="col-sm-4 color2">.col-md-4</div>
</div>
</div>
    
asked by Mendoza 24.05.2017 в 00:31
source

1 answer

0

With your same function, try this:

function myFunction() {
   var alto = document.getElementById("pic").style.height;
   document.getElementById("bigPic").style.height = (alto + tuAumento).toString();
}

So when your function is executed, you should change the height of bigPic. I'm not sure if you have to pass it to string but if that does not work for you, try leaving it like this:

document.getElementById("bigPic").style.height = alto + tuAumento;
    
answered by 24.05.2017 в 08:37