search
HomeWeb Front-endHTML Tutorialdisplay : -webkit-box-inline 我见_html/css_WEB-ITnose

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
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
39 >Product introduction div >
41 div >
42 body >


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 
 3 
 4     
 5     
 6      title >
 7     
 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       style >
69  head >
70 
71     
72          div >
73          产品的名称 产品的介绍 div >
74      div >
75  body >
76  html >


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

Statement
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
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

See all articles

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

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool