CSS左右偏移

html-css013

CSS左右偏移,第1张

1、新建html文件。

2、创建两个div,并赋予id。

3、为两个div设置宽高和背景,并设置左右浮动。

4、预览效果如图。

5、创建第三个div。

6、为第三个div设置宽高和背景。

7、预览效果如图。

注意事项:

随着HTML的成长,为了满足页面设计者的要求,HTML添加了很多显示功能。但是随着这些功能的增加,HTML变的越来越杂乱,而且HTML页面也越来越臃肿。于是CSS便诞生了。

有动画效果的是css3的transition、@keyframes、animation等,css要鼠标移上去后改变状态只能用:hover伪类,暂停动画可以用设置animation-play-state:paused,继续动画是animation-play-state:running (可能需要设置添加-webkit-等私有前缀)其实动画还是推荐jq,实现起来还是挺方便的,而且不用担心浏览器兼容性。

给你写个例子:

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8" />

<title>动画暂停</title>

<style type="text/css">

@keyframes move

{

from {

transform: rotate(0deg)

left: 0

}

to   {

transform: rotate(360deg)

left: 600px

}

}

@-webkit-keyframes move

{

from {

-webkit-transform: rotate(0deg)

left: 0

}

to   {

-webkit-transform: rotate(360deg)

left: 600px

}

}

@-zos-keyframes move

{

from {

-zos-transform: rotate(0deg)

left: 0

}

to   {

-zos-transform: rotate(360deg)

left: 600px

}

}

@-o-keyframes move

{

from {

-o-transform: rotate(0deg)

left: 0

}

to   {

-o-transform: rotate(360deg)

left: 600px

}

}

.box {

animation: move 3s alternate infinite

-webkit-animation: move 3s alternate infinite /* Safari 和 Chrome */

-moz-animation: move 3s alternate infinite /* Firefox */

-o-animation: move 3s alternate infinite /* Opera */

position: absolute

background-color: yellow

width: 100px

height: 100px

}

.box:hover {

-webkit-animation-play-state: paused

}

</style>

</head>

<body>

<div class="box"></div>

</body>

</html>

不知道你问的什么意思。是边框移动?还是css边框就是所说的div?如果是后者,那么正常情况下可以使用maring:top right bottom leftmargin里面填入四个数值分别对应四个方向。例如margin:0px 0px 0px 0px