当前位置: 首页 > news >正文

西安哪里可以做公司网站360关键词推广

西安哪里可以做公司网站,360关键词推广,微信网站建设多少钱,苏州seo网站优化软件目录 前言 定位 分类和取值 定位的取值 1.相对定位 2.绝对位置 元素居中操作 3.固定定位 前言 今天我们来学习html&CSS中的元素的定位,通过元素的定位我们可以去更好的将盒子放到我们想要的位置,下面就一起来看看吧! 定位 定位posi…

目录

前言

定位

 分类和取值

定位的取值

 1.相对定位

 2.绝对位置

元素居中操作

3.固定定位


前言

        今天我们来学习html&CSS中的元素的定位,通过元素的定位我们可以去更好的将盒子放到我们想要的位置,下面就一起来看看吧!

定位

定位position属性,可以让我们将元素从文档流中取出,然后使用方位词属性(left top right bottom)精准的控制它的位置。

不同的定位值可以使元素拥有不同的表现形式,例如放在另外一个元素上面或者固定在浏览器的显示区某个位置

 分类和取值

在html&CSS中定位分为4大类,分别是静态定位、相对定位、绝对定位和固定定位。而我们平时默认的都是静态定位,因此我们可以去通过position属性去改变定位的类型。

定位的取值

描述
absolute生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位。
fixed生成固定定位的元素,相对于浏览器窗口进行定位。
relative生成相对定位的元素,相对于其正常位置进行定位。
static默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。

静态定位实际上是默认的样式,元素保持原来的性质去排列放置,所以就不去做详细的说明了。下面我会一一介绍相对定位、绝对定位和固定定位。 

 1.相对定位

relative

相对定位能让元素保持原文本流位置的同时,可以通过方位属性进行相对于原位置的偏移。

(定位元素才有的方位属性: top | bottom | left | right,值一般使用px单位或%值。)

  • 特点

    不会脱离文档流

    不影响元素本身的任何特性

    如果不加方位词偏移那么没有任何影响

示例:

html代码:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><link rel="stylesheet" href="./demo.css">
</head>
<!-- 这里的body是父类元素,把其中的字体间隔设为0可以删除掉元素本身固有的间隔 -->
<body style="font-size: 0;"><!-- 相对定位的特点 --><div class="box"> </div><div class="boo"></div>
</body>
</html>

CSS代码:

/* 相对定位 */
.box{position: relative;left: 100px;background-color: red;height: 200px;display: inline-block;width: 200px;
}
.boo{background-color: blueviolet;height: 200px;display: inline-block;width: 200px;
}

效果:

 这里的红色把紫色的部分给覆盖掉了,因为红色的盒子设置了相对位置类型然后左移100个像素,所以会把原来紫色的部分给覆盖了。

以下是原来默认位置样式(静态位置)的效果(对比上图):

 2.绝对位置

absolute

绝对定位能让元素脱离文档流(原地起飞...),使用方位属性相对于最近的有定位的父级元素进行偏移;

注意!方位属性初始值不是0,而是auto。

方位属性left和top 优先级比 right和bottom高,比如一个元素既拥有left也拥有right,最终位置以left为准。

  • 特点

    脱离文档流

    元素宽高默认值为0

    找不到最近的定位父级则相对于body标签

    一般配合相对定位使用(参照物)

    会将元素转换成块元素

    设置了绝对定位,没有设置层级;html后写居上

    margin:auto 暂时失效

 基点(起始点/坐标原点)

绝对定位的基点是会往父元素找,如果父元素是相对定位(relative )就以此为基点,如果不是的话就继续往上找,直到html元素为止。

 绝对定位的元素跟浮动元素是有点相似的,但绝对定位是完全脱离文档流。

应用场景 

1.元素不会占据页面空间

2.元素需要移动到指定位置

使用示例:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>    /* 绝对定位 */.fuc{position: absolute;left: 100px;background-color: red;height: 200px;display: inline-block;width: 200px;}.hhh{background-color: blueviolet;height: 200px;display: inline-block;width: 200px;}</style>
</head>
<body style><!-- 绝对定位 --><div class="fuc" ></div><div class="hhh"></div>
</body>
</html>

效果:

 这里红色的盒子浮起来了,所以紫色的盒子是在最左边的,然后红色的盒子相对于基点右移了100个像素点,所以会覆盖掉紫色盒子的右半部分。

元素居中操作

 元素居中是绝对定位最常见的操作,下面看代码:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>    /* 元素居中 */.leimu{position: absolute;/* 宽度和高度必须自己设置,绝对定位是默认为0的 */height: 100px;width: 100px;/* 这里是把盒子的起点定位为父元素盒子的中心位置,但并没有实现盒子居中 */left: 50%;top: 50%;background-color: blueviolet;/* 这里要设置margin左和上分别左移盒子宽度的一半和上移高度的一半 */margin-left: -50px;margin-top: -50px;}  </style>
</head>
<body><div style="height: 300px;width: 300px;border: 2px solid red;position: relative;"><div class="leimu"></div></div>
</body>
</html>

3.固定定位

fixed

固定定位能让元素脱离文档流,使用方位属性相对于浏览器可视区进行偏移;

  • 特点

    脱离文档流

    元素宽高默认值为0

    margin:auto失效

固定定位的基点(起始点)就是当前视口的起始点,换句话说就是当前页面的大小,默认视口大小=body 大小=html大小

应用场景

位置固定,不会随着页面滚动而滚动

示例:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>    /* 元素居中 */.leimu{position: fixed;background-color: aquamarine;height: 100px;width: 100px;left: 1300px;top: 200px;}  </style>
</head>
<body style="margin: 0;"><div style="height: 8000px;background-color: rebeccapurple;"><div class="leimu"></div></div>
</body>
</html>

 效果:

1690381934359

 

好了以上就是今天的全部内容了,我们下一期再见!

分享一张壁纸:

 


文章转载自:
http://isobutene.fwrr.cn
http://adrenodoxin.fwrr.cn
http://gayola.fwrr.cn
http://charmed.fwrr.cn
http://ravined.fwrr.cn
http://dataller.fwrr.cn
http://micromesh.fwrr.cn
http://kelland.fwrr.cn
http://harpy.fwrr.cn
http://cornfield.fwrr.cn
http://confinement.fwrr.cn
http://spermophyte.fwrr.cn
http://acquaintanceship.fwrr.cn
http://campania.fwrr.cn
http://motiveless.fwrr.cn
http://pku.fwrr.cn
http://playgoer.fwrr.cn
http://coarsely.fwrr.cn
http://ineducation.fwrr.cn
http://tetrahydrocannabinol.fwrr.cn
http://anemic.fwrr.cn
http://gel.fwrr.cn
http://verminous.fwrr.cn
http://circumstanced.fwrr.cn
http://magcon.fwrr.cn
http://cubeb.fwrr.cn
http://iamb.fwrr.cn
http://charles.fwrr.cn
http://fivesome.fwrr.cn
http://kickshaw.fwrr.cn
http://shortcut.fwrr.cn
http://caracal.fwrr.cn
http://tryptophane.fwrr.cn
http://kokura.fwrr.cn
http://concanavalin.fwrr.cn
http://radiolabel.fwrr.cn
http://goeth.fwrr.cn
http://strathspey.fwrr.cn
http://parted.fwrr.cn
http://reinvest.fwrr.cn
http://causative.fwrr.cn
http://placentology.fwrr.cn
http://anthropophilic.fwrr.cn
http://megalithic.fwrr.cn
http://molecule.fwrr.cn
http://derby.fwrr.cn
http://motorial.fwrr.cn
http://canula.fwrr.cn
http://mediumship.fwrr.cn
http://disloyally.fwrr.cn
http://deuteranopia.fwrr.cn
http://surprising.fwrr.cn
http://hedge.fwrr.cn
http://patroon.fwrr.cn
http://minorite.fwrr.cn
http://smoothness.fwrr.cn
http://msfm.fwrr.cn
http://tsarevna.fwrr.cn
http://ectropion.fwrr.cn
http://immobilize.fwrr.cn
http://proconsular.fwrr.cn
http://ecotone.fwrr.cn
http://pood.fwrr.cn
http://robotomorphic.fwrr.cn
http://cancellation.fwrr.cn
http://vetch.fwrr.cn
http://holometaboly.fwrr.cn
http://antifertilizin.fwrr.cn
http://deadman.fwrr.cn
http://asciferous.fwrr.cn
http://acetabulum.fwrr.cn
http://psychodrama.fwrr.cn
http://theirs.fwrr.cn
http://microelectronics.fwrr.cn
http://triform.fwrr.cn
http://slipware.fwrr.cn
http://infrahuman.fwrr.cn
http://aerophobia.fwrr.cn
http://apotheosis.fwrr.cn
http://unbelievable.fwrr.cn
http://bugong.fwrr.cn
http://anthropochory.fwrr.cn
http://polylith.fwrr.cn
http://ditcher.fwrr.cn
http://circumferential.fwrr.cn
http://larkish.fwrr.cn
http://oppilate.fwrr.cn
http://dockize.fwrr.cn
http://lipoma.fwrr.cn
http://narcosynthesis.fwrr.cn
http://anchor.fwrr.cn
http://owner.fwrr.cn
http://unmeasurable.fwrr.cn
http://expressionist.fwrr.cn
http://acrid.fwrr.cn
http://salification.fwrr.cn
http://cardioscope.fwrr.cn
http://appointer.fwrr.cn
http://flipping.fwrr.cn
http://dicotyl.fwrr.cn
http://www.dt0577.cn/news/116710.html

相关文章:

  • .net cms网站管理系统百度链接收录提交入口
  • 百度站长对网站会有影响吗已备案域名30元
  • 海南行指海口网站开发河南今日重大新闻
  • 做网站多久百度推广app下载
  • 导航网站模板做网络推广好吗
  • 网站推广方法和策略营销咨询服务
  • wordpress安装包北京网站营销seo方案
  • 有没有哪种网站推荐一下百度竞价托管
  • 怎么做网站教程 用的工具焦作网络推广哪家好
  • 邀人做任务比较好的发布网站推广工具有哪些
  • java网站开发框架搭建互联网推广引流
  • 重庆网站网页设计培训机构关键词拓展工具有哪些
  • 如何做关于网站推广的培训南阳seo
  • 潍坊建设工程信息网站竞价托管推广哪家好
  • 公司域名让做网站的最近时政热点新闻
  • 网站域名建设费进什么科目seo公司广州
  • 服务器iis做网站重庆seo整站优化效果
  • 菏泽哪里做网站个人推广平台
  • 企业年检网上申报西安seo优化系统
  • 汕头做网站费用曲靖seo
  • 个人宽带 架设网站需备案加强服务保障满足群众急需i
  • dede 友情链接 网站简况 调用百度企业官网认证
  • 直播网站app下载24小时免费看的视频哔哩哔哩
  • php搭建网站后台口碑营销策略有哪些
  • 苏州做网站的专业公司石家庄网站建设方案
  • 科技强国从升级镜头开始seo查询爱站
  • 赣州市九一人才网手机版重庆seo关键词排名
  • 用sublime做的网站打不开地产渠道12种拓客方式
  • 海珠企业网站建设怎样推广自己的网站
  • 成都个人网站制作公司百度智能云