Home  >  Q&A  >  body text

The div is not floating very well. I don’t know where the problem lies.

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>jquery的动画效果</title>

<script type="text/javascript" src="jquery-3.3.1.min.js"></script>

<style type="text/css">

.mian{

height:240px;

width: 200px;

margin-right: 20px;

float:left;

}

.box1,.box2 {

height: 200px;

width: 200px;

background: red;

}

button{

height: 40px;

width: 200px;

border:none;}

</style>


<script type="text/javascript">

$(document).ready(function(){

$('.box1').hide()

$('.btu1').click(function(){

$('.box1').fadeIn(1500)

})

$('.btu2').click(function(){

$('.box2').fadeOut(1500)

})

})

</script>

</head>

<body>


<div class="mian">

<button class="btu1">淡入</button>

<div class="box1"></div>

</div>

<br>

<div>

<button class="btu2">淡出</button>

<div class="box2"></div>

</div>

</body>

</html>


依然依然2091 days ago1106

reply all(3)I'll reply

  • TT

    TT2019-02-21 08:44:28

    Are you asking if the animation effect of this is not smooth enough?

    reply
    0
  • 依然

    The problem has been solved. It was caused by an extra
    between the divs. Thank you for your reply.

    依然 · 2019-02-21 09:39:24
  • Cancelreply