current position:Home>How to define and use HTML box model
How to define and use HTML box model
2022-04-29 17:25:32【Billion cloud speed】
html How to define and use the box model
Today I'd like to share with you html How the box model defines the relevant knowledge points used , Detailed content , Clear logic , I believe most people still know too much about this knowledge , So share this article for your reference , I hope you will gain something after reading this article , Now let's take a look .
1.1. The size of the content area of the box — content width and content height — It depends on several factors :
-- Whether the element generating the box is set to 'width' or 'height' attribute .
-- Whether the box contains text and other boxes .
-- Whether the box is a form, etc .
1.2. The background color of the box
-- The background style of the inner margin and border area is generated by ( Of the box ) Elemental 'background' Property to specify . The outer margin background is always transparent
2. Outer margin property : 'margin-top','margin-right','margin-bottom','margin-left' and 'margin'
2.1. The outer margin attribute specifies the width of the outer margin area of the box
--'margin' The shorthand property sets the outer margin around at one time , The other outer margin attributes only set the margin on each side of them . These attributes apply to all elements , But vertical on non substituted inline elements margin There will be no effect
2.2. <margin-width> Value type , You can take one of the following values :
--<length> Specify a fixed width --<percentage> The percentage is based on the number of blocks contained in the generated box width To calculate . Be careful , This is for 'margin-top' and 'margin-bottom' Also applicable . If included, the width of the block depends on the element , So the resulting layout is CSS 2.1 It's undefined --auto--margin Property allows negative values , However, there may be specific implementation limitations
2.3. 'margin-top', 'margin-bottom'
'margin-top', 'margin-bottom'Value: <margin-width> | inheritInitial: 0Applies to: except display The type is table Except for table-caption,table and inline-table All elements other than ( Translation notes : in other words ,table series display In the value ,margin- Only applicable to table-caption, table, inline-table, The rest don't apply , but margin- Right table All series are applicable )Inherited: noPercentages: The reference contains the width of the block Media: visualComputed value: Specified percentage or absolute length
These two attributes are not valid for non replaceable inline elements
2.4. 'margin-right', 'margin-left'
'margin-right', 'margin-left'Value: <margin-width> | inheritInitial: 0Applies to: except display The type is table Except for table-caption,table and inline-table All elements other than ( Translation notes : in other words ,table series display In the value ,margin- Only applicable to table-caption, table, inline-table, The rest don't apply , but margin- Right table All series are applicable )Inherited: noPercentages: The reference contains the width of the block Media: visualComputed value: Specified percentage or absolute length
2.5. 'margin'
'margin'Value: <margin-width>{1,4} | inheritInitial: See individual attributes Applies to: except display The type is table Except for table-caption,table and inline-table All elements other than ( Translation notes : in other words ,table series display In the value ,margin- Only applicable to table-caption, table, inline-table, The rest don't apply , but margin- Right table All series are applicable )Inherited: noPercentages: The reference contains the width of the block Media: visualComputed value: See individual attributes
3. Merge outer margins
Adjacent vertical margins merge , except :
---- Of the root element box margin Do not merge
---- If one has a gap (clearance Translation notes : Refer to clear Attribute causes the position of the element to move ) The upper outer margin of the element is adjacent to the lower outer margin , Its outer margin will be close to the brothers ( Elements ) Merge adjacent outer margins of , But after merging, it will not merge with the lower outer margin of the parent block
That's all “html How to define and use the box model ” All the content of this article , Thank you for reading ! I believe you will gain a lot after reading this article , Xiaobian will update different knowledge for you every day , If you want to learn more , Please pay attention to the Yisu cloud industry information channel .
copyright notice
author[Billion cloud speed],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291539468062.html
The sidebar is recommended
- 07 Chrome browser captures hover element style
- WebGIS development training (ArcGIS API for JavaScript)
- Solution to the blank page of the project created by create react app after packaging
- 19. Html2canvas implements ArcGIS API for JavaScript 4 X screenshot function
- Introduction to JavaScript API for ArcGIS 13
- Development of ArcGIS API for JavaScript under mainstream front-end framework
- Nginx learning notes
- Less learning notes tutorial
- Vue2 cannot get the value in props in the data of the child component, or it is always the default value (the value of the parent component comes from asynchrony)
- LeetCode 217. Determine whether there are duplicate elements in the array
guess what you like
I'll write a website collection station myself. Do you think it's ok? [HTML + CSS + JS] Tan Zi
Front end browser debugging tips
Application of anti chattering and throttling in JavaScript
How to create JavaScript custom events
Several ways of hiding elements in CSS
node. Js-3 step out the use of a server and express package
CSS matrix function
Fastapi series - synchronous and asynchronous mutual conversion processing practice
How to extend the functionality of Axios without interceptors
Read pseudo classes and pseudo elements
Random recommended
- About node JS server related concepts
- Access control module (2)
- About virtual lists
- Developing figma plug-in using Vue 3 + vite
- Learn more about the garbage collection engine of chrome V8 JavaScript engine
- Vue3 uses vite instead of webpack
- How to upload applet code through node? Just take a look
- Using H5 video tag in Vue to play local video in pop-up window
- What is the difference between classes in Es5 and ES6?
- [Vue] play with the slot
- [Part 4 of front-end deployment] using docker to build cache and multi-stage construction to optimize single page applications
- Vue2 simple use of vant (based on Vue CLI)
- node. JS server
- React uses concurrent mode. When the rendering phase exceeds the time slice, high priority tasks jump the queue. How will the lanes on the fiber of the previous task be solved
- Vuecli2 multi page, how to remove HTML suffix
- Vue router dynamically modifies routing parameters
- How to use webpack or configure quasar after context isolation is turned on by electron?
- Vue3 how do parent components call child component methods
- Es learning notes (I): http request
- 【Java WEB】AJAX
- Java project: nursing home management system (java + springboot + thymeleaf + HTML + JS + MySQL)
- Java project: drug management system (java + springboot + HTML + layui + bootstrap + seals + MySQL)
- Java project: agricultural material management system (java + springboot + easyUI + HTML + Maven + MySQL)
- How do Vue, native JS and jQuery feel about development
- The Ajax backend accepts post data and writes it directly to the database
- Java project: agricultural material management system (java + springboot + easyUI + HTML + Maven + MySQL)
- Brother Lao Yu takes you to play with esp32:14 and personally make a two-way wireless remote control (I)
- How to create JavaScript custom events
- A king's time, I learned nginx
- Vue quick start (with actual small items: Notepad, weather forecast, music player)
- Vue: convert user input to numeric type
- - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repom
- vue. config. Understanding of agent in JS
- After the node is successfully installed, CMD can be executed, but the compiler webstorm runs NPM install and prompts that there is no solution to this command
- How to develop and deploy front-end code in large companies
- Vue assigns permissions to buttons through instructions
- [development diary from 22 years to April] Vue problems encountered in actual projects and their solutions
- [methodology 1] CSS development skills - global style setting and local style
- vue3. 0 dynamically bind and obtain DOM through ref;
- How to use HTML for touch event in mobile terminal