这绝对是一道值得深思的题目,帮你明白布局的死角。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> * { margin: 0; padding: 0; } html, body, #app { margin: 0; padding: 0; height: 100%; } #header, #footer { height: 50px; line-height: 50px; text-align: center; background: #555; color: #fff; } #side { width: 200px; background: #eee; } /*css here*/ </style> </head> <body> <div id="app"> <header id="header">header</header> <aside id="side">side</aside> <div id="main"> <ul> <li><a href="https://www.bilibili.com/1">Link1</a></li> <li><a href="https://www.bilibili.com/1">Link2</a></li> <li><a href="https://www.bilibili.com/1">Link3</a></li> <br> <li><a href="https://www.bilibili.com/1">Link4</a></li> <li><a href="https://www.bilibili.com/1">Link5</a></li> </ul> </div> <footer id="footer">footer</footer> </div> <script> // JS here </script> </body> </html>1、完成经典的上 header ,下 footer ,左边是侧边栏,右边是内容。 2、去掉列表前面的 · ,列表项水平排列,注意里面的br标签需要换行,同时每两个li后有一条竖线。 3、点击列表项不跳转,弹出href内的内容。
我的解决方式,是解决了问题,可是都不算完美
#app{ position: relative; } #side{ position: absolute; left: 0; top: 50px; height: calc(100% - 100px); } #main{ margin-left: 200px; height: calc(100% - 100px); }更完美的的方式(或许不能称更完美,只是想到了一些平时布局不会去用的方式,而它却比较使用)
/* css here */ #app{ position: relative; } #side{ position: absolute; left: 0; top: 50px; bottom: 50px; } #main{ position: absolute; left: 200px; top: 50px; right: 0; bottom: 50px; } #footer { /* footer 设置 绝对定位 */ position: absolute; bottom: 0; width: 100%; /* 设置浮动后,补上宽度 */ }暂无
转载于:https://www.cnblogs.com/chenlei987/p/10541961.html