前端整理(一)
1.
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> #wrap { display: table;width: 100%; } #content ,#sidebar { display: table-cell; } #content { background-color: yellow; width: 200px; } #sidebar{ background-color: red; } </style> </head> <body> <div id="wrap"> <div id="content" style="height:340px;">固定</div> <div id="sidebar" style="height:240px;">自适应</div> </div> <div id="footer">后面的一个DIV,以确保前面的定位不会导致后面的变形</div> </body> </html>
2.
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> #content { background-color: #eee; } #sidebar { width: 300px; float: left; height: 400px; } #content { margin-left: 300px; height: 400px; } </style> </head> <body> <div id="wrap"> <div id="sidebar"><img src="big_1.jpg"></div> <div id="content">自适应区</div> </div> </body> </html>
3.
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> #wrap { display: -webkit-box; width: 100%; } #sidebar { width: 300px; -webkit-box-flex:0; background-color: yellow; } #content { -webkit-box-flex:1; background-color: #eee; } </style> </head> <body> <div id="wrap"> <div id="sidebar" style="height:540px;">固定宽度区</div> <div id="content" style="height:340px;">自适应区</div> </div> </body> </html>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步