Home > Web Front-end > HTML Tutorial > css knowledge_html/css_WEB-ITnose

css knowledge_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:43:28
Original
821 people have browsed it

css和html相结合的第一种方式:
1,每一个html标签中都有一个style样式属性,该属性就是css代码
    例:

这是一个div区域

2,使用style样式属性,该属性的值就是css代码。一般定义在head标签中,首先加载
    例:
3,将上面style标记里的内容写在文件div.css中,再导入。div.css放在同一个文件夹中
   
    @import url(div.css);
    
4.直接导入css样式
    (rel表示与页面的关系)
css代码格式:
    选择器名称{属性名:属性值;属性名:属性值;...}
    1,html标签选择器
    2,class选择器
        例:div.biaoqian{}只适用于
div区域1

        .biaoqian{}适用于所有的
    3,id选择器(id值在页面中是唯一的,id通常都是为了去表示页面的一些特定区域使用的)
        例:div.#id1{}只适用于
div区域2

            #id2{}适用于所有的
        优先级:html标记 < class选择器 < id选择器标记 < 标记内属性
4,扩展选择器
1,关联选择器(选择器中的选择器)
例:div b {}只适用于
此区域

2. Combination selector (set like this for multiple tags)
Example: body,div,{background-color:#36F;color:#F23;}
3. Pseudo-element selector
Example: Hyperlink status
a:link{}//Not visited
a:hover{}//The effect of moving the mouse above
a:action{}//Click effect
a:visited{}//After-visit effect
p:first-line The first line of text in the paragraph
p:first-letter{}The first letter in the paragraph
input:focus has The focus element
layout: float
positioning: position:
Attribute: relative relative positioning is positioned according to the original position, and its original position is still
Relative positioning down and to the right is the positive direction
Absolute positioning: Compared to the nearest parent with positioning attributes, the position it originally occupied is gone
z-index level attribute has no unit
css text attribute:
font-size can be set The size of the font em is a multiple of the character unit ex half the px pixel value
text-align sets the text alignment left, right, center, justify both ends
line-height sets the line height of the element
text-indent first line indent
font-weight text thickness set normal to display according to the standard, bold bold display
font-style set text display style normal to display italic according to the standard oblique display
text- decoration sets the text decoration style underline, underline, overline, and line-through strikethrough none to remove the text decoration style.
font-variant font is uppercase small-caps is uppercase normal is standard lowercase
color sets the font color
font-family text font
padding If there are two parameters for the padding, one up and two down If there are three parameters: one up, two left, three down, four parameters top right, bottom left
padding-top padding-left padding-right padding-bottom
margin outer margin, whichever one has a larger margin up or down will have the left and right value. The outer margin is the sum of the two outer margins
margin: 0 auto; the top and bottom margins are 0 pixels, and the left and right margins are automatic, which is equivalent to centering and is suitable for block-level elements. The margins of inline elements are only left and right, not top and bottom
margin can be set is a negative value, padding is not allowed
Block-level elements do not set a specific width, the default is 100%. If a fixed height is not set, the height of the element will change according to the content
Block-level tags are converted into row-level tags p {display:inline;}
Row-level tags are converted to block-level tags a{display:block;} Row-level elements cannot set width and height
Row-level elements cannot use margin: 0 auto; centering must be converted to block level Element
overflow:hidden; Hiding overflowing text can solve the bug of nesting divs and adding float
overflow:scroll; Add scroll bar
overflow:auto; Automatically select
clear:left; Clear on the left Floating
background-image attribute: background image, does not affect the display of text
background-image:url(dog.jpg); Set the background image
background-repeat:; Control the repeating method of the background image
background-position:100px 300px; controls the position of the background. The first parameter represents the distance from the left side of the element, and the second parameter represents the distance from the top of the element
Set multiple elements at the same time: the order is background color background image Background image repetition method Background image distance from the left Distance from the background image from the top
Background-attachment: fixed; Fixed background image
CSS sprite technology: Let an element with a fixed size only display part of the background
Example: background:url(dogs.jpg) no-repeat -370px -230px;
Mouse style cursor: hand is the hand type pointer has strong hand type compatibility crosshair is the cross type text allows you to move to the text Effect wait is the effect of waiting. Default is the default effect. Help is a question mark. e-resize is an arrow to the right. ne-resize is an arrow to the right. nresize is an upward arrow. nw-resize is an arrow to the upper left. w-resize is to the left. Arrow sw-resize downward left arrow s-resize downward arrow se-resize downward right arrow auto The effect automatically given by the system
The visibility attribute is used to control the hiding and display status of the element visible The current element is displayed Status hidden: The current element is in the hidden state. This attribute hides the element. The location is still there
display: none; equivalent to not writing this element, and the position is gone
opacity:0-1; (w3c standard) filter:alpha(opacity=0-100); (IE)
list-style cancel li The far point in
naming convention: id name must be unique. Class can have multiple styles with parent-child relationship, which should be reflected through naming. Reasonable annotation of camel case nomenclature: use_name_box or use-name-box
Priority: Label selector

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template