ToB企服应用市场:ToB评测及商务社交产业平台

标题: CSS常见布局 [打印本页]

作者: 反转基因福娃    时间: 2022-6-26 13:44
标题: CSS常见布局
文章目录



双栏布局


实现思路
一般思路–直接写
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.   <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>双栏布局</title>
  8.    
  9.   </head>
  10.   <body>
  11.    
  12.       
  13.       
  14.    
  15.   </body>
  16. </html>
复制代码
flex弹性布局实现双栏
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>flex弹性布局实现双栏</title>
  8.    
  9. </head>
  10. <body>
  11.    
  12.         zuo
  13.         you
  14.    
  15. </body>
  16. </html>
复制代码
三栏布局

方法汇总:
1、方法1 推荐使用-flex


  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>三栏布局</title>
  8.    
  9. </head>
  10. <body>
  11.    
  12.         左侧
  13.         中间
  14.         右侧
  15.    
  16. </body>
  17. </html>
复制代码
2、方法2


原理:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>三栏布局</title>
  8.    
  9. </head>
  10. <body>
  11.    
  12.         left
  13.         right
  14.         center
  15.    
  16. </body>
  17. </html>
复制代码
3、方法3


原理:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>三栏布局</title>
  8.    
  9. </head>
  10. <body>
  11.    
  12.         左边固定宽度
  13.         右边固定宽度
  14.         中间自适应
  15.    
  16. </body>
  17. </html>
复制代码
4、方法4


原理:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>三栏布局</title>
  8.    
  9. </head>
  10. <body>
  11.    
  12.         中间自适应
  13.    
  14.     左边固定宽度
  15.     右边固定宽度
  16. </body>
  17. </html>
复制代码
5、方法5 推荐使用-grid


  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>三栏布局</title>
  8.    
  9. </head>
  10. <body>
  11.    
  12.         左侧
  13.         中间
  14.         右侧
  15.    
  16. </body>
  17. </html>
复制代码
圣杯布局

圣杯布局的特点

宽度

位置

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>圣杯布局</title>
  8.    
  9. </head>
  10. <body>
  11.     header
  12.    
  13.         center
  14.         left
  15.         right
  16.    
  17.     footer
  18. </body>
  19. </html>
复制代码
双飞翼布局

双飞翼布局由淘宝UED发扬,是通过浮动和定位实现三栏布局的一种方案之一
双飞翼布局的特点

宽度

位置

  1. header
  2. center-inner
  3.   left
  4.   right
  5. footer
复制代码
瀑布流布局


实现方法:

多列布局:

  1.   1
  2.   2
  3.   3
  4.   4
  5.   5
  6.   6
  7.   7
  8.   8
  9.   9
复制代码
弹性布局:

  1.   
  2.     1
  3.     2
  4.     3
  5.   
  6.   
  7.     4
  8.     5
  9.     6
  10.   
  11.   
  12.     7
  13.     8
  14.     9
  15.   
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4