本篇文章中主要的介绍了关于html5 main标签的居中,里面有完整的main标签的用法实例,现在让我们一起来看这篇关于html5 main标签的介绍吧
首先我们先看看html5 main标签要怎么居中:
注释:在一个文档中,不能出现一个以上的
立即学习“前端免费学习笔记(深入)”;
说了这么多定义来看看main标签的居中完整代码实例吧:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP中文网</title>
</head>
<body>
<main align="center">
<h1>PHP中文网</h1>
<p>Google Chrome、Firefox 以及 Internet Explorer 是目前最流行的浏览器。</p>
<article>
<h1>Google Chrome</h1>
<p>Google Chrome是由Google开发的一款免费的开源web浏览器,于2008年发布。</p>
</article>
<article>
<h1>Internet Explorer</h1>
<p>Internet Explorer由微软开发的一款免费的web浏览器,发布于1995年。</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1452">
<img src="https://img.php.cn/upload/ai_manual/001/431/639/68b6ccae3f219838.png" alt="Prisma">
</a>
<div class="aritcle_card_info">
<a href="/ai/1452">Prisma</a>
<p>Prisma是一款照片编辑工具,用户可以轻松地将照片转换成数字艺术。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Prisma">
<span>92</span>
</div>
</div>
<a href="/ai/1452" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Prisma">
</a>
</div>
</article>
<article>
<h1>Mozilla Firefox</h1>
<p>Firefox是一款来自Mozilla的免费开源web浏览器,发布于2004年。</p>
</article>
</main>
</body>
</html>我把main标签里面加上了一个align属性,意思是让整个文档全部往中间对齐,来看看在浏览器中显示的效果:

可以很清楚的看到,因为文章的大小,放不了太大的网页,只能缩小了,但是还是能很清楚的看到这些图片中间的位置的文字。
好了,本篇文章到这也就结束了(想学更多就来PHP中文网,百度搜索PHP中文网,里面有你想要的编程课程和资料),有问题的可以在下方进行提问
【小编推荐】
HTML中ul标签如何去掉点?HTML无序列表的样式实例解析
以上就是html5 main标签怎么居中?main标签的居中实例介绍的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号