css无法移动按钮位置怎么办?

html-css011

css无法移动按钮位置怎么办?,第1张

① 可以给那个按钮设置固定的宽高度width和height,之后设置它的margin:45% 45%;这样,基本上可以水平垂直都居中,而且是随着窗口调整都是这样的居中效果;

<html>

<head>

<meta charset="utf-8">

<style>

.动1{

position: absolute

left: 30px

top: 200px

}

</style>

<script>

function 移动(){

document.getElementById("块").className="动1"

}

</script>

</head>

<body>

<input type="button" onclick="移动()" value="移动" />

<div id="块">你点移动,看我动不动</div>

</body>

</html>

\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a这个是我做的事例代码,希望对你有帮助,定位最主要用到就是这个"position"absolute代表的是绝对位置,还有一个相对位置relative.具体位置的设置就要看margin了,分别有left\right\top\bottom四个位置.自己再调调就好了.