box-flex:也就是让子容器针对父容器的宽高属性按照一定的规则来划分
Eg:
html代码:
CSS样式:
body,div { background:#fff; margin:0; padding:0;}
.wrap { width:600px; height:200px; color:#fff; margin:20px 0 0 20px; text-align:center;
display:-moz-box; display:-webkit-box; display:box;
-moz-box-orient:block-axis; -webkit-box-orient:block-axis; box-orient:block-axis;
-moz-box-direction:reverse; -webkit-box-direction:reverse; box-direction:reverse;
}
.box1 {background:red;
-moz-box-flex:3; -webkit-box-flex:3; box-flex:3;
-moz-box-ordinal-group:1; -webkit-box-ordinal-group:1; box-ordinal-group:1;
}
.box2 {background:green;
-moz-box-flex:1; -webkit-box-flex:1; box-flex:1;
-moz-box-ordinal-group:3; -webkit-box-ordinal-group:3; box-ordinal-group:3;
}
.box3 {background:blue;
-moz-box-flex:2; -webkit-box-flex:2; box-flex:2;
-moz-box-ordinal-group:2; -webkit-box-ordinal-group:2; box-ordinal-group:2;
}
预览效果:
解析:
先看父级元素中设置的属性
1、box-orient:block-axis; 使得子元素按照块级类型竖向显示;
2、box-direction:reverse; 使得子元素显示顺序与默认相颠倒;
再看子元素中的属性(这个以红色区域且标有01文字的模块为例来做详细介绍)
1、box-flex:3; 子元素依照无级元素设置了占有比例。从全局来看,一共将低级元素划分成了6份,而红色区域是占了3/6的,即上图中显示所整体高度的1/2;
2、box-ordinal-group:1; 即给每一个子元素定义了一个组,则按照组的大小来呈现,先小后大; 按照组中定义的大小,本应该是红色居上、蓝色居中、绿色最下显示,而在父级元素中定义了一个子元素的反向呈现方式(box-direction:reverse),即与默认相反;
说到这里,我想大家都豁然开朗了吧!呵呵,当然也存在疑问,如果想让其中某一模块设置为固定数字,那么其他模块又会按怎样的比例来呈现呢?我们可以再看一下下面这个例子(由例1稍做改动)。
静态代码不变、样式由之前的改为:
body,div { background:#fff; margin:0; padding:0;}
.wrap { width:600px; height:200px; color:#fff; margin:20px 0 0 20px; text-align:center;
display:-moz-box; display:-webkit-box; display:box;
-moz-box-orient:block-axis; -webkit-box-orient:block-axis; box-orient:block-axis;
-moz-box-direction:reverse; -webkit-box-direction:reverse; box-direction:reverse;
}
.box1 {background:red;
-moz-box-flex:3; -webkit-box-flex:3; box-flex:3;
-moz-box-ordinal-group:1; -webkit-box-ordinal-group:1; box-ordinal-group:1;
}
.box2 {background:green;
height:100px;
-moz-box-ordinal-group:3; -webkit-box-ordinal-group:3; box-ordinal-group:3;
}
.box3 {background:blue;
-moz-box-flex:2; -webkit-box-flex:2; box-flex:2;
-moz-box-ordinal-group:2; -webkit-box-ordinal-group:2; box-ordinal-group:2;
}
预览效果:
这个时候,绿色模块的高度是固定的,设置为100,占据了父元素的一半。从预览图可以看出,不管哪个模块,一旦设置了固定的宽或者是高,则优先级会比较高。而其他模块呢,还是按照之前的那种思路,用相应比例来显示。要注意的是,这时候的总宽或者高就变了,应
版权声明:本文为博主原创文章,未经博主允许不得转载。

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

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.

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.

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.

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

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

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

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.

Dreamweaver CS6
Visual web development tools
