Home Web Front-end HTML Tutorial display : -webkit-box-inline 我见_html/css_WEB-ITnose

display : -webkit-box-inline 我见_html/css_WEB-ITnose

Jun 24, 2016 am 11:46 AM

Discovered:

I have been working on mobile stuff recently. Speaking of the flexible box layout on the mobile side, it is really good. It is very fun to use. I also discovered this attribute accidentally and its Usage, basically no information about this attribute can be found on the Internet (personal opinion). If you haven’t heard of (display:box), I suggest you go to other people’s blogs and look at CSS3 and you can directly command w. From the word meaning, can you think of the attribute display:inline? If you don’t know, you can take a look. In my last essay, I added -webkit- in front of it because too many people understood box-inline as inline box.

Concept:

We can first think of display:box-inline as a combination with display:inline characteristics and display:box characteristics. It can only display inside the box. Size things and can use a series of attributes of display:box.

Example:

Let’s start with a piece of code:

1 < style >
2 3 🎜> 4 margin: 0;
5 }
6 .content{
7 background-color: #ddd;
8 }
9
10 .content1{
11 background-color: #0f0;
12 }
13
14 .content2{
15 background-color: #0000ff; 🎜> 17
18 .content{
19 display: -webkit-box;
20 height: 300px;
21 }
22
23 .content{
24 -webkit-box-orient: horizontal;
25                                                                                                .            }
31                                              32 .content .content1{
33                                                                                               gt;
38 < div class ="content" >
39 >Product introduction
41
42


After running, careful friends will find that I give The content1 box is set to a width of 40px, but it has no effect. The reason is -webkit-box-flex: 1; it supplements the size of the two boxes on the left and right. Some people will scold me here, "If you want to maintain this feature, just go directly Is it enough to just add display: inline-block to content1? You are so fussy about using it! ”

Reason

But what I want to say is what if I want the text inside to be vertically centered? You said you have a way, and I believe there is a way, but what if the content inside is a picture? What if we want the image to be centered vertically, but at the same time we don’t want it to be distorted? Does it take some effort? There will definitely be such a demand as "the picture on the left, the product title on the right, and the product introduction below." The first thing we think of here is the pack and align of the box. The elements inside will basically be vertically centered, so we change content1 to -webkit-box and add the box-pack:center; box-align:center; attribute. At this time, we found that the content inside was indeed vertically centered but the width still did not change.

At this time try to change the box of content1 to -webkit-box-inline We will be surprised to find:

1. The size of the box becomes 40px

2 .The text inside the box is also vertically centered

3. The box with inline feature can actually change the size

Let’s summarize again at this time, it can change its own size and the initial size is only within the box My first impression of the volume was definitely the inline-block. At this time, I couldn’t help but marvel at how many people didn’t find such an easy-to-use feature using it! Let me summarize it here.

display : -webkit-box-inline

has the following features:

  1. has the feature of display:inline-block: render the object as an inline object , but the object's contents are rendered as a block object, and the adjacent inline objects are rendered on the same line, spaces allowed. My crude explanation - the box can only accommodate the size of the child elements when initialized, and the box itself can be resized.
  2. Has the display:box attribute and can use the CSS3 features


Personally, I think this attribute is particularly useful if used properly.

Final example code:


 1 
 2  < html >
 3  < head  lang ="en" >
 4      < meta  charset ="UTF-8" >
 5      < meta  name ="viewport"  content ="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"   />
 6      < title >
 7      < style >
 8          * {
 9              padding: 0;
10              margin:  0;
11          }
12          .content{
13              background-color: #ddd;
14          }
15 
16          .content1{
17              background-color:  #0f0;
18          }
19 
20          .content2{
21              background-color:  #0000ff;
22          }
23 
24          .content,
25          .content .content2{
26              display:  -webkit-box;
27              display:  -moz-box;
28              display:  box;
29          }
30 
31          .content .content2,
32          .content .content1{
33              -webkit-box-align:  center;
34              -moz-box-align:  center;
35              box-align:  center;
36              -webkit-box-pack:  center;
37              -moz-box-pack:  center;
38              box-pack:  center;
39          }
40 
41          .content {
42              height:  300px;
43          }
44 
45          .content{
46              -webkit-box-orient:  horizontal;
47              -moz-box-orient:  horizontal;
48              box-orient:  horizontal;
49          }
50 
51          .content .content2,
52          .content .content1{
53              -webkit-box-flex:  1;
54              -moz-box-flex: 1;
55              box-flex: 1;
56          }
57 
58          .content .content1{
59              width:  300px;
60              height:  100%;
61              display:  -webkit-inline-box;
62          }
63 
64          .content .content1 img{
65              width: 100%;
66          }
67 
68      
69 
70  < body >
71      < div  class ="content" >
72          < div  class ="content1" >< img  src ="3.jpg.680.510.jpg" >
73          < div  class ="content2" >产品的名称 < br />产品的介绍
74     
75 
76 


以上都是在谷歌浏览器上运行的。
经常的总结让我们变得更智慧,让我们在迷茫的时候找到前进的方向!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML: Building the Structure of Web Pages HTML: Building the Structure of Web Pages Apr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML: Is It a Programming Language or Something Else? HTML: Is It a Programming Language or Something Else? Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

What is the difference between <strong>, <b> tags and <em>, <i> tags? What is the difference between <strong>, <b> tags and <em>, <i> tags? Apr 28, 2025 pm 05:42 PM

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

See all articles