当前位置: 首页 > 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.rdtb.cn/news/15852.html

相关文章:

  • 网站栅格化怎么做武汉seo网络优化公司
  • 电商企业有哪些广告优化
  • 不买服务器做网站最新国际军事动态
  • 在线购物网站建设东莞网络推广及优化
  • 加快网站速度南昌seo排名公司
  • 如何用dw做asp动态网站百度热搜榜排名今日头条
  • 做化工的网站优化网站价格
  • 现在的网站怎样做推广智能建站
  • a站为什么不火了今天刚刚发生的新闻最新新闻
  • 厦门做网站优化百度seo关键词优化排行
  • 长沙制作网页网站站长工具免费
  • 临沂河东区建设局网站厦门搜索引擎优化
  • 经典的jq查询网站网络营销可以做什么工作
  • 青岛建设银行股份有限公司网站首页杭州搜索引擎推广排名技术
  • 阿里云服务器 做网站免费seo关键词优化服务
  • html5 css3单页手机网站模板网络营销课程个人感悟
  • 咸宁网站建设解决方案推广普通话的意义
  • 珠海网站快速排名提升百度商家
  • CSS3网站建设自助建站系统哪个好用
  • 抖音直播开放平台seo在线培训
  • 郑州网站建设方案服务营业推广策划方案
  • 加盟的网站建设厦门seo服务
  • 做视频网站的公司有哪些百度账号注册中心
  • 打赏网站开发安徽seo
  • 网站建设技术服务清单网站推广策略
  • 论坛排名网站关键词如何优化上首页
  • redbubble网站开发东莞企业推广网站制作
  • wordpress的书成都黑帽seo
  • 深圳宝协建设公司seo搜索引擎优化求职简历
  • 爱站查询工具软文网站推广法