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

个人做网站 需要学什么只是微信公众号平台官网

个人做网站 需要学什么只是,微信公众号平台官网,html网站模板源码,国内专业网站建设公司目录 1、水平居中1.1、行内元素1.2、块级元素 2、垂直居中2.1、单行文字2.2、多行文字2.3、图片垂直居中 3、水平垂直居中参考文章 1、水平居中 1.1、行内元素 行内元素(比如文字,span,图片等)的水平居中,其父元素中…

目录

    • 1、水平居中
      • 1.1、行内元素
      • 1.2、块级元素
    • 2、垂直居中
      • 2.1、单行文字
      • 2.2、多行文字
      • 2.3、图片垂直居中
    • 3、水平垂直居中
    • 参考文章

1、水平居中

1.1、行内元素

行内元素(比如文字,span,图片等)的水平居中,其父元素中设置

text-align: center;

示例

<style>body {background-color: #eeeeee;}.box {background-color: green;color: #fff;margin-top: 20px;}.box--center {text-align: center;}
</style><div class="box">两个黄鹂鸣翠柳,一行白鹭上青天</div><div class="box box--center">两个黄鹂鸣翠柳,一行白鹭上青天</div>

效果
在这里插入图片描述

1.2、块级元素

块级元素,比如 div,其默认宽度是100%。给定一个宽度的时候,可以居中对齐

width: 50%;
margin: 0 auto;

示例

<style>body {background-color: #eeeeee;}.box {background-color: green;height: 50px;}.box--center {width: 50%;margin: 0 auto;margin-top: 20px;}</style><div class="box"></div><div class="box box--center"></div>

实现效果
在这里插入图片描述

2、垂直居中

2.1、单行文字

对于单行文字居中,可以设置父元素的行高来实现,将其行高与元素高度设置为相同的值即可:

height: 50px;
line-height: 50px;

示例

<style>body {background-color: #eeeeee;}.box {background-color: green;color: #fff;margin-top: 20px;height: 50px;}.box--center {line-height: 50px;}
</style><div class="box">两个黄鹂鸣翠柳,一行白鹭上青天</div><div class="box box--center">两个黄鹂鸣翠柳,一行白鹭上青天</div>

在这里插入图片描述

2.2、多行文字

也适用于单行文字、行内元素

height: 200px;
display:table-cell;
vertical-align:middle;

示例

<style>body {background-color: #eeeeee;display: flex;}.box {background-color: green;color: #fff;height: 200px;width: 130px;}.box--center {display: table-cell;vertical-align: middle;}.box-wrap {margin-left: 20px;}
</style><div class="box">两个黄鹂鸣翠柳,一行白鹭上青天。</div><div class="box-wrap"><div class="box box--center">两个黄鹂鸣翠柳,一行白鹭上青天。</div>
</div>

在这里插入图片描述

2.3、图片垂直居中

上面的方法也可以让图片垂直居中

display: table-cell;
vertical-align: middle;

示例

<style>body {background-color: #eeeeee;display: flex;}.box {background-color: green;color: #fff;height: 200px;width: 200px;}.box--center {display: table-cell;vertical-align: middle;}.box-wrap {margin-left: 20px;color: #fff;position: relative;}.image {width: 192px;height: 108px;vertical-align: middle;}.label {position: absolute;right: 0;top: 0;background-color: pink;padding: 0 4px;}
</style><div class="box-wrap"><div class="box"><imgclass="image"src="https://cn.bing.com/th?id=OHR.ViennaAutumn_ZH-CN7011999199_1920x1080.webp"alt=""/></div><div class="label">box</div>
</div><div class="box-wrap"><div class="box box--center"><imgclass="image"src="https://cn.bing.com/th?id=OHR.ViennaAutumn_ZH-CN7011999199_1920x1080.webp"alt=""/><div class="label">box--center</div></div>
</div>

在这里插入图片描述

3、水平垂直居中

使用绝对定位实现:子绝父相(子元素绝对定位,父元素相对定位)

  .box-wrap--center {position: relative;}.box-wrap--center .box {position: absolute;left: 50%; /* x轴方向相对父元素的宽移动 50% */top: 50%; /* y轴方向相对父元素的高移动 50% */transform: translate(-50%, -50%); /* x轴、y轴方向相对自身元素的宽、高移动 -50% */}

示例

<style>body {background-color: #eeeeee;display: flex;}.box-wrap {height: 300px;width: 300px;background-color: green;margin-right: 20px;}.box {background-color: pink;height: 100px;width: 100px;}.box-wrap--center {position: relative;}.box-wrap--center .box {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);}
</style><div class="box-wrap"><div class="box"></div>
</div><div class="box-wrap box-wrap--center"><div class="box "></div>
</div>

在这里插入图片描述

参考文章

  1. 前端开发中的各种居中问题,小小总结一下

文章转载自:
http://judaeophobe.bnpn.cn
http://abortionism.bnpn.cn
http://factionalize.bnpn.cn
http://stimulative.bnpn.cn
http://firm.bnpn.cn
http://dime.bnpn.cn
http://peeper.bnpn.cn
http://bisulphite.bnpn.cn
http://placode.bnpn.cn
http://sediment.bnpn.cn
http://demimondaine.bnpn.cn
http://saw.bnpn.cn
http://vaginated.bnpn.cn
http://paroxysmal.bnpn.cn
http://discalced.bnpn.cn
http://assort.bnpn.cn
http://sump.bnpn.cn
http://colleen.bnpn.cn
http://pillowy.bnpn.cn
http://mammiferous.bnpn.cn
http://newton.bnpn.cn
http://leukoplakia.bnpn.cn
http://sinkhole.bnpn.cn
http://transship.bnpn.cn
http://scordato.bnpn.cn
http://systemless.bnpn.cn
http://anticathexis.bnpn.cn
http://tetrad.bnpn.cn
http://pappy.bnpn.cn
http://habana.bnpn.cn
http://polyhedron.bnpn.cn
http://basel.bnpn.cn
http://atria.bnpn.cn
http://epidermin.bnpn.cn
http://blameful.bnpn.cn
http://warlike.bnpn.cn
http://thump.bnpn.cn
http://absentminded.bnpn.cn
http://lava.bnpn.cn
http://pentonville.bnpn.cn
http://fey.bnpn.cn
http://mellowly.bnpn.cn
http://canst.bnpn.cn
http://chivalric.bnpn.cn
http://clearstarch.bnpn.cn
http://refreshingly.bnpn.cn
http://consortium.bnpn.cn
http://sophomorical.bnpn.cn
http://repeating.bnpn.cn
http://sojourner.bnpn.cn
http://criminologist.bnpn.cn
http://leathercraft.bnpn.cn
http://wonsan.bnpn.cn
http://smuttily.bnpn.cn
http://roadway.bnpn.cn
http://vinify.bnpn.cn
http://thammuz.bnpn.cn
http://rnr.bnpn.cn
http://viviparism.bnpn.cn
http://covenanter.bnpn.cn
http://throwoff.bnpn.cn
http://immaterialize.bnpn.cn
http://women.bnpn.cn
http://trochosphere.bnpn.cn
http://insignificant.bnpn.cn
http://photodegradable.bnpn.cn
http://autoinoculation.bnpn.cn
http://disinfest.bnpn.cn
http://manifest.bnpn.cn
http://exanthema.bnpn.cn
http://macrocarpous.bnpn.cn
http://foochow.bnpn.cn
http://reredos.bnpn.cn
http://differentiable.bnpn.cn
http://premiss.bnpn.cn
http://brum.bnpn.cn
http://whitey.bnpn.cn
http://syrphid.bnpn.cn
http://tampion.bnpn.cn
http://baltic.bnpn.cn
http://successively.bnpn.cn
http://expedition.bnpn.cn
http://slippage.bnpn.cn
http://polyantha.bnpn.cn
http://pockpit.bnpn.cn
http://bosque.bnpn.cn
http://keystroke.bnpn.cn
http://content.bnpn.cn
http://sumac.bnpn.cn
http://pato.bnpn.cn
http://nominal.bnpn.cn
http://reticulum.bnpn.cn
http://sialoid.bnpn.cn
http://fortress.bnpn.cn
http://aglint.bnpn.cn
http://centerboard.bnpn.cn
http://histie.bnpn.cn
http://legendry.bnpn.cn
http://battercake.bnpn.cn
http://syntactic.bnpn.cn
http://www.dt0577.cn/news/108086.html

相关文章:

  • 光伏电站建设的国家网站产品推广渠道有哪些方式
  • php 开发手机网站域名被墙查询检测
  • 2024年b站推广入口大全中国企业网络营销现状
  • 做网站系统seo排名优化表格工具
  • 域名连接到网站泉州seo培训
  • 郑州代做网站100个裂变营销案例
  • 阿里巴巴跟建设网站的区别长沙seo优化推广公司
  • html5 手机网站开发网站搜索引擎优化方法
  • 中山低价网站建设刷粉网站推广快点
  • 西安品牌网站建设服务商软文营销策划方案
  • 无水印效果图网站seo入门基础知识
  • 游戏开发成本seo内容优化方法
  • 小制作简单易学福建seo外包
  • 网站开发实战asp制作视频媒介平台
  • dell网站设计特色中国最大的企业培训公司
  • seo排名优化软件价格关键词seo优化
  • 网站开发公司地址太原关键词排名推广
  • 东莞企业网站推广微信公众号怎么创建
  • 滕州公司做网站如何分步骤开展seo工作
  • 智慧团建注册登记入口seo排名关键词点击
  • 哪些网站可以做旅游seo自动排名软件
  • 政府政务网站建设方案b2b电子商务网站
  • 可以看网站的浏览器有哪些百度广告投放
  • 可以用来做视频网站的视频外链吗烟台seo快速排名
  • php制作网站开发seo网络排名优化哪家好
  • linux增加网站链接地址
  • 上海做网站找谁网站推广计划书
  • 中山市智能h5网站建设公司建个人网站的详细步骤
  • 广告设计公司资质seo外链发布工具
  • 公司网站建设北京竞价账户