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

做网站平台的公司有哪些企业网站seo推广方案

做网站平台的公司有哪些,企业网站seo推广方案,ppt网站源码,网站后台中表格制作文章目录 flex绝对定位margin:auto绝对定位margin:负值定位transformtext-align: center;margin: 0 auto;思维导图 后文&#xff1a;【前端】CSS垂直居中的7种方法_karshey的博客-CSDN博客 左右两边间隔相等的居中 flex display: flex;justify-content: center; <div clas…

文章目录

    • flex
    • 绝对定位+margin:auto
    • 绝对定位+margin:负值
    • 定位+transform
    • text-align: center;
    • margin: 0 auto;
    • 思维导图

后文:【前端】CSS垂直居中的7种方法_karshey的博客-CSDN博客

左右两边间隔相等的居中

flex

  • display: flex;
  • justify-content: center;
<div class='parent'><div class="son"></div>
</div>
.parent {display: flex;justify-content: center;
}
.son {background: pink;width: 100px;height: 100px;
}

绝对定位+margin:auto

  • 居中子元素
  • 子绝父相,子元素margin:auto

原理:

top + margin-top + border-top-width + padding-top + height + padding-bottom + border-bottom-width + margin-bottom + bottom = height
上述式子中,top和bottom为0,margin等于auto,此时浏览器为了满足这个等式会把上下的距离均匀分给margin,即达到我们想要的居中效果。横向也是一样的道理。

.father {position: relative;width: 500px;height: 500px;background-color: blue;
}.center {position: absolute;left: 0;right: 0;top: 0;bottom: 0;margin: auto;width: 100px;height: 100px;background-color: red;
}
<div class='father'><div class="center"></div>
</div>

绝对定位+margin:负值

原理:对当前元素的position设置为absolute,并且相对于父元素定位。先设置left:50%;top:50%,使当前元素的左上角处于父元素的中心位置。之后再应用负margin特性使其中心位于父元素的中心。因此需要知道子元素的大小。挪动子元素大小的一半。

.father {position: relative;width: 500px;height: 500px;background-color: blue;
}.center {width: 200px;height: 100px;background-color: red;position: absolute;left: 50%;margin-left: -100px;
}
<div class='father'><div class="center"></div>
</div>

若想要垂直也居中,则需要center中添加:

top: 50%;
margin-top: -50px;

利用负margin实现元素居中

定位+transform

  • 父元素:相对定位
  • 子元素:相对/绝对 定位 都可以
  • 子元素left:50%,左边界到父元素的中间
  • 子元素transform: translateX(-50%);,向左移动自己的一半,使得自己的中心对准父元素的中心
  • 不需要知道子元素宽度
.father {position: relative;height: 500px;width: 500px;background-color: blue;
}.center {position: relative;left: 50%;width: 200px;height: 200px;background-color: red;transform: translateX(-50%);
}
<div class='father'><div class="center"></div>
</div>

text-align: center;

指定元素文本的水平居中。是行内元素

  • text-align: center;
.parent {text-align: center;
}
<div class='parent'><span>123</span>
</div>

margin: 0 auto;

  • margin: 0 auto;
  • 定宽,不定宽的话宽为width:100%
  • 块级元素
<div class='box'>是块级元素居中,块级元素内的不居中,想让这行文字也居中要用text-align</div>
.box {background: skyblue;width: 200px;height: 200px;margin: 0 auto;
}

思维导图

在这里插入图片描述

css 水平居中(8种方法)、垂直居中(8种方法) - 掘金 (juejin.cn)

绝对定位+margin auto垂直居中引发的思考 - 掘金 (juejin.cn)

使用transform使定位元素居中_transform居中_神膘护体小月半的博客-CSDN博客

http://www.hkea.cn/news/794132/

相关文章:

  • 丽水专业网站建设价格青岛网站优化
  • 网站开发专业培训学校百度推广登录官网入口
  • 贵阳做网站公司网站热度查询
  • 做课件最好的素材网站考拉seo
  • 网站建设玖首选金手指seo网站优化收藏
  • 台州卓远做网站好不好广州seo教程
  • dz网站数据备份bt磁力猪
  • github 可以做网站吗360seo
  • 杭州 企业门户网站建设爱链
  • dj那个网站做的好长沙公司网络营销推广
  • 设计师培训招生视频黑帽seo联系方式
  • 做网上贸易哪个网站好西宁网站seo
  • 电子烟网站建设杯子软文营销300字
  • 广州企业网站制作怎么做营销推广
  • 网站建设服务器在香港郑州网站建设专业乐云seo
  • 河北建设工程交易信息网海口关键词优化报价
  • 全国网站建设公司有多少家微信朋友圈广告投放收费标准
  • 免费做网站公司黑帽seo排名技术
  • apk连接wordpress上海seo
  • 企业建网站租用服务器好还是买一个好石家庄网站关键词推广
  • wordpress文件解析外贸网站优化
  • 建设工程竣工备案网站百度保障中心人工电话
  • 韶关城乡建设部网站首页营销型网站建设策划书
  • 建设银行手机银行下载官方网站谷歌浏览器网页版入口在哪里
  • 网站建设 好域名注册信息
  • 公众号微网站建设认证哪个推广网站好
  • 爬取1024上传到wordpress蔡甸seo排名公司
  • 流感吃什么药更好seo的方法
  • 营销型网站建设市场seo黑帽技术有哪些
  • 扬中做网站的公司seo虚拟外链