我正在尝试使用HTML和CSS在用户点击它时使段落标记从左向右移动。我怎么能这样做?
答案 0 :(得分:1)
您可以使用jQuery的 animate
来移动元素。请检查以下示例:
$(document).ready(function(){
$("button").click(function(){
$(".text-box").animate({left: '250px'});
});
});
.text-box{
background:#98bf21;
height:auto;
max-width:400px;
width:auto;
position:absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button>Move Element!!</button>
<div class="text-box""><p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p></div>