css怎么调整div的位置

html-css011

css怎么调整div的位置,第1张

可以使用css中的position来对div进行定位来改变div的位置,position可能的值如下:

工具原料:编辑器、浏览器

1、通过设置一个div的position的值来调整div的位置,简单的代码示例如下:

body>

<div id="div2"></div>

<style>

div{

border: 1px solid red

width: 200px

height: 200px

position: absolute

right: 200px

bottom: 200px

}

</style>

</body>

2、设置一个宽高为200像素的div距body的右边200像素底部200像素,运行的效果如下图:

在css中设置字体和div的位置:

在css中设置字体,一般情况下,我们都是通过font这个css属性来完成,font-family:"字体名字(如:微软雅黑)"还可以使用font-size对字体的大小做限制,如font-size:12px;

div的位置,我们首先需要知道你要将你的这个div固定的位置,也就是left和top,在使用position的定位来做就行,这里给出具体的代码:

<html>

<head>

<style>

.headr{

width:300px

height:200px

border:1px

solid

#f00

position:absoulte

left:100px

//只是假定的值,具体需测量

top:200px

}

</head>

<body>

<div

class="headr"

>

//页头

</div>

</body>

</html>