HTML中进行页面布局可以做哪些操作
Admin 2022-08-24 群英技术资讯 532 次浏览
合理的页面布局,是所有HTML页面的一个基础。
1.可以利用表格,构建页面的布局,在进行内容的填充。
2.使用div,配合float或者flex对页面进行布局。
早期的方法,就是利用table表格来进行页面的布局。
一个简单的table布局:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表格</title> </head> <body> <table border="1" cellspacing="1" cellpadding="1" align="center"> <tr> <td colspan="2" align="center" style="background: #0395e1">顶部导航</td> </tr> <tr> <td style="background: #f25807" align="center" height="300px" width="100px"> 内<br>容<br> <br>侧<br>栏 </td> <td style="background: red" align="center" width="400px"> 主要内容 </td> </tr> <tr> <td colspan="2" style="background: darkorchid" align="center">底部</td> </tr> </table> </body> </html>
显示效果:
用div布局:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>div布局</title> </head> <body> <header style="background: #83c44e;width: 500px;height: 100px;text-align: center;line-height: 100px">顶部导航</header> <main style="text-align: center;width: 500px"> <div align="center" style="background: #0395e1;width: 100px;height: 400px;float: left">内<br>容<br> <br>侧<br>栏</div> <div style="background: darkorchid;float: left;width: 400px;height: 400px;line-height: 400px">主要内容</div> </main> <footer style="background: red;width: 500px;text-align: center;line-height: 50px">底部</footer> </body> </html>
把float换成flex同样的效果:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>div布局</title> </head> <body> <header style="background: #83c44e;width: 500px;height: 100px;text-align: center;line-height: 100px">顶部导航</header> <main style="text-align: center;width: 500px;display: flex"> <div align="center" style="background: #0395e1;width: 100px;height: 400px;">内<br>容<br> <br>侧<br>栏</div> <div style="background: darkorchid;width: 400px;height: 400px;line-height: 400px">主要内容</div> </main> <footer style="background: red;width: 500px;text-align: center;line-height: 50px">底部</footer> </body> </html>
页面显示效果:
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
后代选择器:定义的时候用空格隔开。交集选择器:定义的时候紧密相连。并集选择器:定义的时候用逗号隔开。
本文主要介绍了纯html+css实现打字效果,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
这篇文章主要介绍了使用CSS的border-radius属性 设置圆弧,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
CSS容器背景颜色渐变怎样实现呢?一些朋友可能会遇到这方面的问题,对此在下文小编向大家来讲解一下,内容详细,易于理解,希望大家阅读完这篇能有收获哦,有需要的朋友就往下看吧!
css3框模型有5种属性:1、width属性,设置内容的宽度;2、height属性,设置内容的高度;3、padding属性,设置内边距;4、margin属性,设置外边距;5、border属性,设置边框。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008