Understanding of the box model, the Box Model
A very important concept in CSS is the box model. When CSS processes a webpage, it considers that each element is contained in an invisible box.It consists of the space (inner margin, padding) around the content area and the outer edge (border, border) of the inner margin) and the Invisible Area (margin, margin) that separates the elements from the adjacent elements outside the border. For example, the width of the element in the browser is inconsist
need to know how to perform hack in CSS. Here is an example that can achieve this effect in multiple General browsers:
Doctype html > Html > Head > Style > HTML, body, P { Margin : 0 ; Padding : 0 ; Font-family : Sans-serif ; } . Ellipsis { Overflow : Hidden ; Height : 200px ; Line-height : 25px ; Margin : 20px ; Border : 5px solid # aaa ; } . Ellipsis: before { Content : "" ; Float : Left ; Width : 5px ; Height : 200px ;
Examples of css box models and css box models
1. Overview of the css Box Model
1> let's take a look at w3c overview.
2> In fact, each element of css is a box (Box Model)
2.css box model type
1> w3c standard model ---------> element space width = content + border + padding + margin
2> traditional IE model (IE6-) -----> element = content (border + padding) + margin
3. Usage of box-sizing
1> attribute: box-
operationOff-topic: Each element has a box model, and there are two ways to calculate the width of the element in the world:One is the standard (width and width of the element, excluding padding and border),The other is the traditional box model (the width includes the width of the elements themselves plus padding and border).2. Input box set width:100%, Overflow parent class container Box-sizing:border-box, which indicates that the size of the element is any width within the border , that is,
-height:1000px; Transition:. 3s ease;}
11. Inheriting box-sizing
Let box-sizing inherit HTML:
HTML { Box-sizing:border-box;} *, *:before, *:after { box-sizing:inherit;}
This makes it easier to change the box-sizing in other components of the plug-in or leverage other behaviors.
12. Width of table cells
Tables are cumbersome to work with, so be s
item.
7. Use negative Nth-child to select items
Use negative nth-child in CSS to select item 1 to Project N.
Li { display:none;} /* Select items 1 through 3 and display them */li:nth-child (-n+3) { display:block;}
8. Use SVG for icons
There is no reason for us not to use SVG for icons:
. logo { background:url ("Logo.svg");}
SVG has good extensibility for all resolution types and allows all browsers to return to IE9. This avoids. png,. jpg, or. gif files.
9. Optimize display text
Sometime
loading speed faster, then what to violate the smoothness of the slide, the user may have to enter the page when more than fraction second load time feel little, but the real-time calculation of sliding the height of the lag is obviously able to experience, the individual think it is not as good as the beginning (iOS8 more excessive, Even if they are all good, they will draw the edge of the calculation)
IOS8 self-sizing CellCell with dyna
many browsers, if your project does not consider the low version of IE, you can rest assured that the use of, if your project in the low version of IE still occupy a lot of proportion, then you are still worried about the use of REM is not compatible and is not daring to use. In fact, it is not necessary to do some processing for the lower version of IE browser: { font-size: 62.5%;} { font-size: 14px; font-size: 1.4rem/** * H1 { font-size: 24px; font-size: 2.4rem/** *This solves the probl
, with the editor batch modification can also, just the following more elegant point):
//# #IMG @img-path: '. /img ';//img button@weixin: ' @{img-path}/[email protected] '; @weixin-hover: ' @{ Img-path}/[email protected] '; @qq: ' @{img-path}/[email protected] '; @qq-hover: ' @ {Img-path} /[email protected] '; @weibo: ' @{img-path}/[email protected] '; @weibo-hover: ' @{img-path}/[email protected] ';
The color of the General page is determi
.
Use the attribute abbreviation whenever possible.
Attribute prefix. The standard attribute is placed at the end, and aligned with the colon to facilitate reading and multi-line editing in the editor..box {-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
Attribute writing sequence: Location> box model> layo
[html_css]12 CSS Advanced Tips Summary2016-08-01 Category: Html_css_js note reading ( 0) The following CSS advanced techniques, the average person I do not tell him oh.
Use: Not () apply/deselect border on menu
Add row height to body
Everything is centered vertically
Comma-delimited list
Use negative nth-child to select items
Use SVG for icons
Optimize display text
Use Max-height for pure CSS Sliders
Inherit box-s
the scroll bar in iOS? Is the above two properties, but it turns out that Android also supports this attribute, so simply use Woindow.scroll.Suppress text selection:-webkit-user-select:noneProhibit users from selecting text, both iOS and Android supportShielding Shadows:-webkit-appearance:nonePro-Test, you can also block the input box strange inner shadow, to solve the iOS cannot modify the button style, the test also found that a small problem is that the above attributes, iOS default or with
Transferred from: http://www.w3cplus.com/css3/how-to-use-css3-calc-function.htmlCalc () may be a stranger to everyone, and it's unlikely to believe that Calc () is part of the CSS. Since it looks like a function, why does the function appear in CSS? This also makes me baffled, today a colleague told me that there is a property in CSS3 to achieve adaptive layout, first let me think of is box-sizing, but with me said can also calculate, which let me thi
fluid layout, simply set the length to a percentage.two. box-sizingIn the Box model section, we learned that the total length of the element box would increase if the padding padding and border border were added. So if this element is used for very precise layout, we need to calculate the increment or decrease. This is actually a more annoying operation, especially when the page layout is dynamically set.CSS3 provides an attribute box-sizing that de
the above two properties, but it turns out that Android also supports this attribute, so simply use Woindow.scroll.Suppress text selection:-webkit-user-select:noneProhibit users from selecting text, both iOS and Android supportShielding Shadows:-webkit-appearance:none. Be able to block the input frame at the same time weird inner shadows. Fix the button style can not be changed under iOS, test also found a small problem is. With the above attribute added, the default or rounded corner of iOS is
using CSS ResetCSS Reset can maintain a consistent style style on different browsers. You can use the CSS Reset library normalize, etc., or you can use a more streamlined reset method:* { border-box; 0; 0;} Now that the element's margin and padding are 0, box-sizing you can manage the layout of your CSS box model.Note: If you follow the next inheritancebox-sizingTo explain this technique, you do not need to add in the above codebox-sizingProperty.
Calc () may be a stranger to everyone, and it's unlikely to believe that Calc () is part of the CSS. Since it looks like a function, why does the function appear in CSS? This also makes me baffled, today a colleague told me that there is a property in CSS3 to achieve adaptive layout, first let me think of is box-sizing, but with me said can also calculate, which let me think of Calc (). Because earlier on the official website and some blog to see the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.