current position:Home>How to use the box pack attribute and box align attribute inside the box in HTML
How to use the box pack attribute and box align attribute inside the box in HTML
2022-04-29 17:25:36【Billion cloud speed】
html Align the inside of the middle box box-pack Properties and box-align How to use attributes
This article mainly introduces “html Align the inside of the middle box box-pack Properties and box-align How to use attributes ”, In daily operation , I believe a lot of people are html Align the inside of the middle box box-pack Properties and box-align There are doubts about how to use attributes , Xiao Bian consulted all kinds of materials , Sort out simple and easy-to-use operation methods , I hope to answer ”html Align the inside of the middle box box-pack Properties and box-align How to use attributes ” Your doubts help ! Next , Please follow Xiaobian to learn !
When elastic elements and inelastic elements are mixed for typesetting , It is possible that the size of all child elements is larger or smaller than the size of the box , Thus, there is insufficient or surplus space in the box . At this time, we need a way to manage the space of the box . If the total size of the child element is less than the size of the box , You can use box-align and box-pack Attribute management .
CSS3 Newly added box-pack Properties and box-align attribute , Used to define the inside of the box element “ Subelement ” The management of surplus space in the horizontal and vertical directions . These alignments , For the text inside the box element 、 Graphics and child elements are valid .
One 、 Horizontal alignment box-pack attribute
box-pack Property can manage the free space of the box horizontally .
Two 、 Vertical objects box-align attribute
box-align Property can manage the free space of the box in the vertical direction .
3、 ... and 、 The practical application
stay CSS2 in , If you want to center the text vertically , It's often set height The property value is equal to line-height Property value , But after learning this section , We just have to let div Element usage box-align attribute ( The default arrangement direction is horizontal), The text can be centered vertically .
give an example 1: Adaptive Text centering ( Including vertical centering and horizontal centering )
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title> Box internal alignment box-pack Properties and box-align attribute </title> <style type="text/css"> div { width:200px; height:160px; display:-webkit-box; -webkit-box-align:center; -webkit-box-pack:center; background-color:pink; } </style></head><body> <div> Billion speed cloud </div></body></html>
give an example 2: Picture adaptive centering ( Including vertical centering and horizontal centering )
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title> Box internal alignment box-pack Properties and box-align attribute </title> <style type="text/css"> #control { margin-bottom:10px; } #view { width:160px; height:100px; display:-webkit-box; -webkit-box-orient:horizontal; -webkit-box-align:center; -webkit-box-pack:center; border:1px solid silver; } </style> <script src="jquery-1.11.3.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#range_width").change(function () { var num = $(this).val(); $("#value_width").text(num + "px"); $("#view").css("width", num + "px"); }); $("#range_height").change(function () { var num = $(this).val(); $("#value_height").text(num + "px"); $("#view").css("height", num + "px"); }); }) </script></head><body> <div id="control"> Width :<input id="range_width" type="range" min="160" max="320" value="160"/><span id="value_width">160px</span><br /> Height :<input id="range_height" type="range" min="100" max="240" value="100"/><span id="value_height">100px</span> </div> <div id="view"><img src="../App_images/lesson/run_css3/css3.png" alt=""/></div></body></html>
Here we are , About “html Align the inside of the middle box box-pack Properties and box-align How to use attributes ” That's the end of my study , I hope we can solve your doubts . The combination of theory and practice can better help you learn , Let's try ! If you want to continue to learn more related knowledge , Please continue to pay attention to Yisu cloud website , Xiaobian will continue to strive to bring you more practical articles !
copyright notice
author[Billion cloud speed],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291539467960.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