I'm new to javascript, I'm wondering how to get .contact from a 30% width to 40% when I go with my mouse over .contact. This works, but while .contact gets bigger I want .div to get smaller from 70% width to 60%, so .div won't get under .contact.
This is what I have at the moment:
var width = 30;
var maxWidth = 40;
var interval = null;
var contact = document.getElementById("contact");
function myMove() {
interval = setInterval(function() {
if (width>= maxWidth){
return clearInterval(interval);
}
contact.style.width = ++width + "%";
},5);
}
.contact{
background-color:red;
width:30%;
float:left;
}
.div{
background-color: blue;
width: 70%;
float: right;
}
<div class="content">
<div class="contact" id="contact" onmouseover="myMove()">
<h3> Text</h3>
<p>More textt</p>
</div>
<div class="div">
<h3> Text</h3>
<p>More textt</p>
</div>
</div>
Do you know how to do this?