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

从化建网站网站建设去哪里找客户

从化建网站,网站建设去哪里找客户,网页制作与网站发布,色彩搭配比较好的网站博主目前在蚂蚁集团-体验技术部,AntV/S2 是博主所在团队的开源项目——多维交叉分析表格,欢迎使用,感谢到 S2 github 仓库点赞 star,有任何关于前端面试、就业、技术问题都可给在文章后留言。 1、盒子宽度和高度是已知的。思路&a…

博主目前在蚂蚁集团-体验技术部,AntV/S2 是博主所在团队的开源项目——多维交叉分析表格,欢迎使用,感谢到 S2 github 仓库点赞 star,有任何关于前端面试、就业、技术问题都可给在文章后留言。

1、盒子宽度和高度是已知的。思路:
  • 父元素相对定位;
  • 子元素绝对定位;
  • left: 50%; top: 50%;
  • margin-left: 负的一半宽度; margin-top: 负的一半高度。
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>盒子垂直水平居中demo1</title><style type="text/css">html,body {height: 100%;position: relative;overflow: hidden;}.box {height: 150px;width: 300px;background-color: antiquewhite;border: 2px solid #000;line-height: 146px;text-align: center;position: absolute;top: 50%;left: 50%;margin-top: -75px;margin-left: -150px;}</style>
</head>
<body><div class="box">盒子垂直水平居中</div>
</body>
</html>
2、盒子宽度和高度是未知的(有高、宽,但是不知道)。思路:
  • 父元素相对定位;
  • 子元素绝对定位;
  • top: 0; right: 0; bottom: 0; left: 0;
  • margin: auto;
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>盒子垂直水平居中demo2</title><style type="text/css">html,body {height: 100%;position: relative;overflow: hidden;}.box {height: 150px;width: 300px;background-color: antiquewhite;border: 2px solid #000;line-height: 146px;text-align: center;position: absolute;top: 0;right: 0;bottom: 0;left: 0;margin: auto;}</style>
</head>
<body><div class="box">盒子垂直水平居中</div>
</body>
</html>
3、平移:定位 + transform。思路:
  • 父元素相对定位;
  • 子元素绝对定位;
  • top: 50%; left: 50%;
  • transform: translate(-50%, -50%);
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>盒子垂直水平居中demo3</title><style type="text/css">html,body {height: 100%;position: relative;overflow: hidden;}.box {background-color: antiquewhite;border: 2px solid #000;line-height: 146px;text-align: center;position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);}</style>
</head>
<body><div class="box">盒子垂直水平居中</div>
</body>
</html>
4、flex 布局。思路:
  • 在父级元素中采用flex布局:display: flex; justify-content: center; align-items: center;
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>盒子垂直水平居中demo4</title><style type="text/css">html,body {height: 100%;overflow: hidden;display: flex;justify-content: center;align-items: center;}.box {height: 150px;width: 300px;background-color: antiquewhite;border: 2px solid #000;line-height: 146px;text-align: center;}</style>
</head>
<body><div class="box">盒子垂直水平居中</div>
</body>
</html>
5、父元素:display: table-cell 布局。思路:
  • 父元素:display: table-cell; vertical-align: middle; text-align: center;
  • 父元素有固定的宽高;
  • 子元素:display: inline-block;
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>盒子垂直水平居中demo6</title><style type="text/css">.box1 {height: 300px;width: 600px;background-color: blue;display: table-cell;vertical-align: middle;text-align: center;overflow: hidden;}.box2 {display: inline-block;height: 150px;width: 300px;background-color: antiquewhite;border: 2px solid #000;line-height: 146px;text-align: center;}</style>
</head>
<body><div class="box1"><div class="box2">盒子垂直水平居中</div></div>
</body>
</html>
6、通过JavaScript的方式。思路:
  • 父元素相对定位;
  • 子元素绝对定位;
  • 获取父元素的 clientHeight 和 clientWidth;
  • 获取子元素的 offsetHeight 和 offsetWidth;
  • 计算子元素的 top 和 left。
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>盒子垂直水平居中demo6</title><style type="text/css">html,body {height: 100%;overflow: hidden;position: relative;}.box {height: 150px;width: 300px;background-color: antiquewhite;border: 2px solid #000;line-height: 146px;text-align: center;position: absolute;}</style>
</head>
<body><div class="box" id="box">盒子垂直水平居中</div><script type="text/javascript">let HTML = document.documentElement,winH = HTML.clientHeight,winW = HTML.clientWidth,boxH = box.offsetHeight,boxW = box.offsetWidth;box.style.top = (winH - boxH) / 2 + "px";box.style.left = (winW - boxW) / 2 + "px";</script>
</body>
</html>

博主水平有限,若发现文中存在问题,欢迎留言指正!

学习之路永无止境!
http://www.yayakq.cn/news/741847/

相关文章:

  • 福田网站设计方案国内网页设计网站
  • 专业做视频的网站阿里云上做网站
  • 信息流广告素材网站网站排名网络推广
  • 天津住房和城乡建设厅官方网站vue开发wordpress
  • 长沙做网站公司 上联网络个体户可以做企业网站
  • 时尚风格网站龙岩做网站开发要多久
  • 轻应用网站模板列举网络推广的方式
  • 青岛企业自助建站系统专业网页制作与网站设计
  • 做笑话网站赚钱吗千牛网页版登录入口
  • 阿雷网站建设苏州工业园区招聘官网
  • 怎么看网站是哪家公司做的什么是网页布局
  • 网站推广运营如何做网站个人
  • 怎么建立自己企业网站app代理
  • 虚拟主机建设网站两个wordpress 加ico
  • 互联网网站 权限全网浏览器
  • 做招聘网站毕业设计php和网站开发
  • 长治做网站购买网站做友情链接
  • 做数据库与网站招什么人win10 中国建设银行网站
  • 河北精品网站建设企业网站托管电话
  • 大通证券手机版下载官方网站下载网站seo报表
  • 网站开发常见毕业设计题目展览公司前十名
  • 慈溪做网站什么价开滦建设集团网站
  • 清远市住房和城乡建设局网站无锡网站推广哪家好
  • 做设计转钱网站视觉差网站插件
  • 网站建设的收费盘锦企业网站建设
  • 做网站为什么要用固定ip廊坊网站设计制作
  • 装修公司怎么做免费网站赣州人事人才网
  • 企业网站建设规划设计任务书海尔网站建设信息
  • 建设网站有哪些好处h5自响应式网站模版
  • mysql 学习网站wordpress首页缩略图不显示