Good afternoon !! Home
I'm trying to run the following code however I'm not aware how to resize the image to the size of the div, so it cuts the image and takes only the center :(
Can you help me??
function clickImagem(src)
{
$('#conteudo').empty();
var el = document.getElementById('conteudo');
$(el).css('background',"url('"+src+"') no-repeat center ");
}
#conteudo{
height:200px;
width:200px;
float:left;
background-color:#f1f;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="conteudo" class="conteudo"> </div>
<img src="https://tudocommoda.com/wp-content/uploads/2017/02/colar-de-namorados-cora%C3%A7%C3%A3o-1.jpg"onclick="clickImagem(this.src)">