4
Good morning !!
Here’s what I’m trying to do:
I created a Function that when clicking on the photo, sends the photo to the circular div conteudo
, the problem is that if the image is larger than the div, it overlaps everything, I would like to treat it to be whole but inside the div as in the photo:
(Red current photo without treatment) (Blue the desired mode)
function clickImagem(src)
{
$('.conteudo').empty();
var el = document.getElementById('conteudo');
$('#conteudo').css('background',"url('"+src+"') no-repeat center");
$('#conteudo-foot').empty();
}
.conteudo{
width:320px;
height:300px;
border-radius:50%;
border:0.1px solid #000;
z-index:5;
background:#fff;
margin: 35px auto;
-webkit-box-shadow: 0 0 10px rgba(0,0,0, 0.7);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="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)">
</html>
Can you help me please?
You want the image to stay inside the circle, losing the parts that go beyond the circle or you want the square image to stay inside the circle?
– Felipe Avelar
So I’d like to know how I get the image to stay inside the blue circle
– Sora