css笔记(就是书中的一些摘抄^

    技术2022-05-11  55

    divs should be used to group related items based on their meaning or function rather than their presentation or layout. Whereas divs can be used to group block-level elements, spans can be used to group or identify inline elements: div只是一个分块的标签,他可以将网页分成几个区块。div里面可能包含一个标题,一个段落,也可能包含图片在内的很多元素,甚至div也可以再包含div。而span是行级元素(行内标签),通常情况下它都用来定义一小段文字的样式。它们的另一个区别就是div会造成换行,而span则不会。 Unfortunately, IE 6 automatically switches to quirks mode if the DOCTYPE declaration is not the first element on a page. Therefore, unless you are serving your pages as XML documents, it is best to avoid using an XML declaration The most common kinds of selectors are type and descendant selectors 可以用id指定某一个元素,用class指定某一类元素 ID selectors are identified using a hash character; class selectors are identified with a period. :link and :visited are known as link pseudo-classes and can only be applied to anchor elements. :hover, :active, and :focus are known as dynamic pseudo-classes and can theoretically be applied to any element. Child and adjacent sibling selectors Attribute selectors a rule written in a style attribute will always be more specific than any other rule. A rule with an ID will be more specific than one without an ID, and a rule with a class selector will be more specific than a rule with just type selectors. Finally, if two rules have the same specificity, the last one defined prevails. -------------------------------------------------------------------------------------------- Every element on the page is considered to be a rectangular box made up of the element’s content, padding, border, and margin Margin collapsing   Margin collapsing only happens with the vertical margins of block boxes in the normal flow of the document. Margins between inline boxes, floated, or absolutely positioned boxes never collapse. There are three basic positioning schemes in CSS: normal flow, floats, and absolute positioning. Block-level boxes will appear vertically one after the other; the vertical distance between boxes is calculated by the boxes’ vertical margins.Inline boxes are laid out in a line horizontally. An absolutely positioned element is positioned in relation to its nearest positioned ancestor. Gradients Tiling images 在css中,任何东西都可用看成一个element 以div为例,它的大小默认和content area的相同,如果设置了padding等的话,content的大小不变,但是div的大小会增加。 Image Replacement

    最新回复(0)