Blogger Information
Blog 28
fans 0
comment 1
visits 13104
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
盒模型属性,媒体查询及em、rem
centos
Original
413 people have browsed it

盒模型属性,媒体查询及em、rem

盒模型属性

常用的盒模型属性有margin padding border
div的尺寸计算方式为(margin+padding+border)*2+width
内容裁切:background-clip: content-box
padding margin 属性值的顺序是:上 右 下 左

  1. .box {
  2. width: 200px;
  3. height: 200px;
  4. margin: 20px;
  5. padding: 20px;
  6. border: 3px dashed;
  7. background-color: aqua;
  8. background-clip: content-box;
  9. }

媒体查询

  1. @media (max-width: 450px) {
  2. .min {
  3. background: #bdc200;
  4. }
  5. }
  6. @media (min-width: 450px) and (max-width: 800px) {
  7. .min {
  8. background: pink;
  9. width: 100px;
  10. height: 50px;
  11. }
  12. }
  13. @media (min-width: 800px) {
  14. .min {
  15. background: red;
  16. width: 200px;
  17. height: 100px;
  18. }
  19. }

通过像素变化做手机端适应。

em rem的区别
em是相对于父元素的大小
rem是相对于根元素的大小

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!