CSS Learning notes (i)

Source: Internet
Author: User

1. Background

Background:url () No-repeat left center red;

Background-repeat, Background-position, Background-image, Background-color

2, the style of the text

Font-size change the size of text

Font-weight Bold text

font-family fonts

Font-style Italic Italic Normal

Text-indent Indent 10px 2em

FONT:12PX/2 Arial,sans-serif; The font-size is 12px, the line-height is twice times the font-size, and the rear is the font. Maybe this is the least of the font.

The difference between Em,px,rem

PX is the font size, after writing, even if the page is enlarged, the font should not become larger

EM is a unit, such as the parent font-size is 12px, the child set font-size bit 2em, then the font-size true size of the child is 24px;

<div style= "FONT-SIZE:12PX;" > I was testing </div>
<div style= "FONT-SIZE:12PX;" ><p style= "FONT-SIZE:2EM;" > I was testing </p></div>

If the parent is set to EM, the child is set to EM, then the child's true size is the parent's em* child's EM, look at the following example

*{margin:0; padding:0; list-style:none;}

body{font-size:12px;}

P{font-size:2em;}
. div1{Font-size:2em;}
. div2{Font-size:2em;}

<div class= "Div1" > I test </div>
<div class= "Div2" >
<p> Me in Test </p>
</div>

If you set em to the body's font-size, the default font size for the browser is odd, which is usually 16px, which is body{font-size:1em;} Equivalent to Body{font-size:16px;},font-size can also be used as a percentage

For REM, a new unit of CSS3, if the parent is REM and the child is REM, then the true rem of the child is the value of the subset

3, from the outside to the inside, from top to down write page

4, White-space:nowrap Mandatory text does not change line, text-overflow:ellipsis plus ellipsis overflow:hidden; Overflow Hide

5, CSS writing position: style= "CSS style"--inline style

<style type= "text/css" ></style> inline style

6. HTML entity Symbol

&lt; <

&gt; >

7, IE6 does not support the hover of a label other than a

8, Div#box (Forbidden) Div.box must be a div and have a class is box

In front of the selector, it is best to limit the range, and all spans in the span page are selected.

Note: Inheritance is not directly given to the large.

Inherit #box. Text

Direct to span

This tag will perform the style of span

9. CSS style inheritance

Font-size, Font-weight, font-family, Font-style, Line-height,

Color->a Special, cannot inherit colors from parent

10.

Block Tags: div p h1

Exclusive row

can give the width of the high

Width is 100% when the width is not given

In-line label: a span

A line of coexistence

Can not give the width of the height, width and height by the content to prop up

Inline block Tags: img input

I can give you a wide, high-side line

Nested rules:

Block: Can set the block label and inline label. But P is special, it can no longer contain other block tags.

Inline: Only inline labels can be nested.

  IE6 does not support inline-block of blocks

HTML semantics: What label to use with what label, with big Wrap small, do not want to achieve the appearance, disorderly use label. Don't change HTML for CSS

11. When to use pictures

When the image appears as content in the Web page, use the img

When a picture is used as a modifier (optional), use background

12, UL unordered list, OL have sequence table,<dl><dt> title </dt><dd> content One </dd><dd></dd></dl> description list

13, Box model: Width+padding+border, margin is not part of the box model

Note: The margin and padding of the labels in the row are incomplete and only left and right are not up or down.

Block margin collapse

The margin-top of the bottom element, the margin-bottom of the upper element, and the distance between the Margin-top and Margin-bottom are the largest.

    Note: Collapse only exists on top and bottom! Margin is okay.

14, Margin-top merger

A merge occurs when there is no border,padding between the margin-top of the parent and the margin of the child, and the parent and child have Margin-top

Solve the problem:

1. Add a border to the parent level

2. Parent plus Padding-top (recommended) height (second)

3. Parent Overflow:hidden (recommended)

can use padding (recommended), is to use padding, because margin will have some problems.

15. Floating:

Floating Characteristics:

1. Floating out of document flow

Other elements when floating things do not exist, occupy the position of the floating element

2. Text Wrapping

3, floating can let the block to a row

4, floating is the order of left, right

5, after floating, the parent width is not enough to be squeezed down

6, after floating, the elements will be squeezed down with the highest elements go

7, after floating, inline variable block (can give wide height)

Floating three elements:

1, there is an element floating, the sibling elements are floating

2, there is a float, you must clear the floating

3, floating elements, must have width (preferably with width, although sometimes without the width of the thing)

16, no semantic tags: i, B, span and so on.

17.

    

CSS Learning notes (i)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.