CSS review (III)

Qiao spicy chicken 2021-08-08 18:41:29
css review iii


CSS Knowledge review ( 3、 ... and )

css Layout , Responsive knowledge

notes : I've drawn attention to what I've done demo、 But you can't see it in the Nuggets , For details, please refer to my personal blog : www.11qiaolj.github.io

Tradition float Layout

In traditional float There are several common layout methods in layout , stay pc The end is particularly commonly used

1. Two column layout

That is, the left side is fixed , Adaptive layout on the right . Relatively simple .

Left floating fixed width

On the right margin Separate the left width

2. Double wing layout

On the left , The right side is fixed , Middle adaptive layout . Often appear .

Self use margin Left and right make room for left and right

Left box margin-left:-100%

Right side box margin-left:- Self width

3. The holy grail layout

Similar to the twin wing layout .

The difference is , For the layout of the Holy Grail padding Set aside left and right positions

Left box margin-left:-100% + right: Self width

Right side box margin-right:- Self width

Responsive layout

In order to adapt to different mobile phone screen sizes , Responsive layout came into being .

Not only on the mobile side , Various web pages for various devices are applied to responsive layout .

1. Media query +rem

rem Is a unit based on the font size of the root node , It can change with the size of the root node font

Such as html Of font-size by 100px, that 1rem=100px.

Based on this principle , We can divide the screen into 10 Share ( Any number of copies )

So it corresponds to 1024 Pixel screen , let html Of font-size=102.4px

If it is 670 Pixel screen , let html Of font-size=67px namely 1rem=67px

In this way, we can gradually change according to the change of screen size rem You can achieve responsive layout

that , How do we get the size of the screen ? We used a media query ,media-query It can help us get the size of the current screen grammar :

@media screen and (max-width:800px){
html{
font-size:80px; !important
}
}
 Copy code 

This code means , The screen is smaller than 800px when , Root node font size is 80px

Use the media to search +rem It is true that a responsive layout can be achieved in this way .

But the related problem is , Responsive layout can only define the size of the root font in one section , It has the characteristics of stepwise change , It doesn't change in real time .

2.vw and vh Instead of rem

because rem The disadvantages of ladder ,vw and vh Brought solutions

  • vh yes window.innerHeight Viewport height 1/100.
  • vw yes window.innerWeight Viewport height 1/100.

3.flex Elastic layout

Combine the previous rem and vw,flex Elastic layout provides a different way from traditional layout float Layout method , The arrangement of elements is realized through the main axis and side axis

display:flex // The parent container is flex Elastic box
flex-direction: row/columns // Define spindle direction
flex-warp:warp/nowarp // Define whether to wrap
justify-content:flex-start | flex-end | center | space-between | space-around;
// Define the arrangement of elements on the spindle Head alignment Tail alignment In the middle Edge at both ends around
align-items:flex-start | flex-end | center | baseline | stretch;
// Define the arrangement of elements on the secondary axis Head alignment Tail alignment In the middle The baseline fill
align-self:auto | flex-start | flex-end | center | baseline | stretch;
// Define the position of an element on the secondary axis head tail Bureau The baseline fill
flex:1; // Represents adapting to the remaining space
 Copy code 

among ,flex:1 It's a key interview question ;

flex:1 It's made up of three attributes .

  • flex-grow:1, Stands for automatically filling the remaining space
  • flex-shrink:1, Represents compression , Will compress inward .
  • flex-basis:0, Represents his own basic width ,0 That is, no width . These three attributes are combined to form “ Elastic box ”

4.grid Grid layout

grid Layout is a new way of layout , Provide elements in 2 The arrangement on the dimensional plane . The disadvantage is that some browsers are incompatible .

display:grid // The parent container is set to grid grid
grid-template-colums/rows:1fr // Set rows / The size of each column
column/row-gap: // Set rows / Column spacing
grid-template-areas: // Set area
"a1 a1 a1"
"a2 a3 a3"
"a2 a3 a3";
align-items:/justify-items: // vertical / Horizontal alignment
grid-colum-start/end: // Start / End position
 Copy code 

It is worth noting that grid Is based on 2 Dimensional , and flex It does face one-dimensional

版权声明
本文为[Qiao spicy chicken]所创,转载请带上原文链接,感谢
https://qdmana.com/2021/08/20210808183744970v.html

  1. HTML + CSS + JavaScript to achieve cool Fireworks (cloud like particle text 3D opening)
  2. HTML + CSS + JavaScript realizes 520 advertising love tree (including music), which is necessary for programmers to express themselves
  3. Solve the problem of Web front-end deployment server (it can be deployed online without a server)
  4. HTML + CSS + JS make wedding countdown web page template (520 / Tanabata Valentine's Day / programmer advertisement)
  5. What else can driverless minibus do besides "Park connection"?
  6. Cloud native leads the era of all cloud development
  7. NRM mirror source management tool
  8. Bring it to you, flex Jiugong
  9. Lolstyle UI component development practice (II) -- button group component
  10. Deconstruction assignment in ES6
  11. Luo 2 peerless Tang clan was officially launched. The official gave a key point, and the broadcast time was implied
  12. 20初识前端HTML(1)
  13. 当新零售遇上 Serverless
  14. 20 initial knowledge of front-end HTML (1)
  15. When new retail meets serverless
  16. [golang] - go into go language lesson 5 type conversion
  17. [golang] - go into go language lesson 6 conditional expression
  18. HTML5(八)——SVG 之 path 详解
  19. HTML5 (8) -- detailed explanation of SVG path
  20. 需要开通VIP以后页面内容才能复制怎么办?控制台禁用javascript即可
  21. Web前端|CSS入门教程(超详细的CSS使用讲解,适合前端初学者)
  22. 实践积累 —— 用Vue3简单写一个单行横向滚动组件
  23. Serverless 全能选手,再下一城
  24. What if you need to open a VIP to copy the page content? Just disable JavaScript on the console
  25. Web front end | CSS introductory tutorial (super detailed CSS explanation, suitable for front-end beginners)
  26. Practice accumulation - write a single line horizontal scroll component simply with vue3
  27. Dili Reba is thin again. She looks elegant and high in a strapless hollow skirt, and her "palm waist" is beautiful to a new height
  28. Serverless all-round player, next city
  29. The difference between MySQL semi synchronous replication and lossless semi synchronous replication
  30. Vue表单设计器的终极解决方案
  31. The ultimate solution for Vue form designer
  32. Nginx从理论到实践超详细笔记
  33. Yu Shuxin's red backless swimsuit is split to the waist and tail, with a concave convex figure and excessive color matching, and his face is white to dazzling
  34. Nginx ultra detailed notes from theory to practice
  35. 【动画消消乐|CSS】086.炫酷水波浪Loading过渡动画
  36. typecho全站启用https
  37. CCTV has another popular employee. The off-site interpretation is very professional, and the appearance ability is no less than that of Wang Bingbing
  38. [animation Xiaole | CSS] 086. Cool water wave loading transition animation
  39. Enable HTTPS in Typecho
  40. 50天用JavaScript完成50个web项目,我学到了什么?
  41. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  42. What have I learned from completing 50 web projects with JavaScript in 50 days?
  43. "My neighbor doesn't grow up" has hit the whole network. There are countless horse music circles, and actor Zhou Xiaochuan has successfully made a circle
  44. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  45. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  46. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  47. 30 + women still wear less T-shirts and jeans. If they wear them like stars, they will lose weight
  48. 数栈技术分享前端篇:TS,看你哪里逃~
  49. Several stack technology sharing front end: TS, see where you escape~
  50. 舍弃Kong和Nginx,Apache APISIX 在趣链科技 BaaS 平台的落地实践
  51. Abandon the landing practice of Kong and nginx, Apache apisik on the baas platform of fun chain technology
  52. 浪迹天涯king教你用elementui做复杂的表格,去处理报表数据(合并表头,合并表体行和列)
  53. 前端HTML两万字图文大总结,快来看看你会多少!【️熬夜整理&建议收藏️】
  54. Wandering around the world king teaches you to use elementui to make complex tables and process report data (merge header, merge table body rows and columns)
  55. 路由刷新数据丢失 - vuex数据读取的问题
  56. Front end HTML 20000 word graphic summary, come and see how much you can【 Stay up late to sort out & suggestions]
  57. Route refresh data loss - vuex data reading problem
  58. Systemctl系统启动Nginx服务脚本
  59. Systemctl system startup nginx service script
  60. sleepless