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

网站自适应屏幕百度关键词怎么排名

网站自适应屏幕,百度关键词怎么排名,连云港做网站的,地税局内网网站建设目录 1采用flex弹性布局: 2子绝父相margin:负值: 3.子绝父相margin:auto: 4子绝父相transform: 5通过伪元素 6table布局 7grid弹性布局 文字 水平垂直居中链接:文字水平垂直居中-CSDN博客 以下为盒子…

目录

 1采用flex弹性布局:

2子绝父相+margin:负值:

3.子绝父相+margin:auto:

4子绝父相+transform:

5通过伪元素

6table布局

7grid弹性布局


文字 水平垂直居中链接:文字水平垂直居中-CSDN博客

以下为盒子水平垂直居中

<template><div><div class="father"><div class="son"></div></div></div>
</template>

 1采用flex弹性布局:

在父元素设置display: flex表示该容器内部的元素将按照flex进行布局,再设置align-items: center表示这些元素将相对于本容器水平居中,justify-content: center实现垂直居中。

.father{width: 400px;height: 300px;background-color: rebeccapurple;display: flex;justify-content: center;align-items: center;
}
.son{width: 200px;height: 100px;background-color: aqua;
}
效果

2子绝父相+margin:负值:

设置left和top为50%,此时位置会偏右自身元素的宽高,再设margin-left和margin-top为自身元素宽高的负一半,实现水平垂直居中。


.father {width: 400px;height: 300px;background-color: rebeccapurple;position: relative;
}
.son {width: 200px;height: 100px;background-color: palegoldenrod;position: absolute;top: 50%;left: 50%;//宽度的一半margin-left: -100px;//高度的一半margin-top: -50px;
}
效果:

3.子绝父相+margin:auto:

,设置top、left、right、bottom为0,在设置margin:auto

.father{width:400px;height:300px;background-color: rebeccapurple;position: relative;   //父级设置为相对定位}.son{width:100px;height:40px;background: red;position: absolute;   //设置为子级绝对定位top:0;left:0;right:0;bottom:0;margin:auto;}
效果

4子绝父相+transform:

设置left和top为50%,此时位置会偏右自身元素的宽高,再设transform: translateX(-50px) translateY(-50px);

.father{width: 400px;height: 300px;background-color: rebeccapurple;position: relative;
}
.son{width: 200px;height: 100px;background-color: skyblue;position: absolute;left: 50%;top: 50%;transform: translateX(-100px) translateY(-50px);
}
效果

5通过伪元素

.father{width: 400px;height: 300px;background-color: rebeccapurple;text-align: center;
}
.father::before{content : '';display: inline-block;vertical-align: middle;height: 100%;
}
.son{width: 200px;height: 100px;background-color: pink;vertical-align: middle;margin: 0 auto;display: inline-block;
}
效果

6table布局

设置父元素为display:table-cell,子元素设置 display: inline-block。利用verticaltext-align可以让所有的行内块级元素水平垂直居中。

.father {display: table-cell;width: 400px;height: 300px;background: rebeccapurple;vertical-align: middle;text-align: center;
}
.son {display: inline-block;width: 200px;height: 100px;background: forestgreen;
}
效果

7grid弹性布局

在父元素设置display: drid表示该容器内部的元素将按照flex进行布局,再设置align-items: center表示这些元素将相对于本容器水平居中,justify-content: center实现垂直居中。

.father{width: 400px;height: 300px;background-color: rebeccapurple;display: grid;justify-content: center;align-items: center;
}
.son{width: 200px;height: 100px;background-color: greenyellow;
}
效果

http://www.dinnco.com/news/36712.html

相关文章:

  • 公司做网站建设价格市场调研报告
  • 设计学专业蜗牛精灵seo
  • 学院网站建设意义网络搜索词排名
  • 网站建设 常用字体外贸网站推广平台
  • 桓台建设网站百度客户端
  • 网站建设 善辉网络网上销售都有哪些平台
  • iis5.1 建立网站附近电脑培训速成班一个月
  • 青岛北京网站建设外贸平台
  • 庆阳设计公司苏州seo优化公司
  • 网站如何做绿标网站页面的优化
  • 免费做网站页头图谷歌在线浏览入口
  • 贵州今天疫情新增消息前端优化
  • 有限责任公司和有限公司的区别毕节地seo
  • 美文的手机网站免费职业技能培训网
  • 区块链做网站都有哪些内容呢免费网站站长查询
  • 网站开发人员工作内容查询百度关键词排名
  • 自己做的网站被黑了怎么办网络营销怎么做推广
  • 做网站的公司好坑啊软文推广的优点
  • 网站下载下来怎么做后台惠州seo排名
  • 免费信息发布潍坊网站建设seo
  • 关于做网站的问卷调查微信朋友圈广告怎么推广
  • 移动端网站的优势人力资源培训
  • 网站建设周期计划北京最新疫情
  • asp个人网站建设seo短视频
  • 公司做的网站费用计入什么科目世界杯最新排名
  • 营销型网站建设一般包含哪些内容免费b站推广网站破解版
  • 做项目接任务的网站全球搜索引擎市场份额
  • 东莞网站建设案例今天今日新闻头条最新消息
  • 浦东教育网站官网免费网站推广网站破解版
  • 我想建设网站四川餐饮培训学校排名