CSS (art part Knowledge, understanding) 1, CSS Overview 1.1, CSS is what?
* CSS refers to cascading style sheets
Style sheets: Where to store styles
Stacking: One layer, one layer overlay
Tall and handsome and irritating 1.2, CSS has what role?
*css is used to make it easier to decorate HTML tags (elements) 1.3, CSS Code specification
Selector Name {property Name: property value; Property Name: Property value; ...}
Separating attributes from attributes by semicolons
property is concatenated with the property value directly by using a colon
If a property has multiple values, then multiple values are separated by a space. For example: border:5px solid red;
Comment:/* Comment content */
Add Note: ctrl+shift+/
Uncomment: ctrl+shift+\s 2, the combination of HTML and CSS
*css must be used in conjunction with HTML.
* 4 ways to use: 2.1, style attribute mode (inline style)
* Suitable for local modification of one label
*<font style= "font-size:150px;color:red;" > Fine weather Today </font> 2.2, style tag: (inline style)
*<style></style> exists in the head tag.
* For example: <style type= "Text/css" >
Font {
font-size:150px;color:red;
}
</style>
* Multiple tabs of the page set a uniform style. 2.3. Import method (less used in external style)
* Format: @import url ("CSS file path");
* Existing in <style> tags 2.4, link mode (the most common way of external style)
* Format: <link rel= "stylesheet" type= "Text/css" href= "CSS file path"/>
* Existing in
External style Benefits:
Greatly improves the reusability of code, makes it easier to maintain, and greatly increases work efficiency.
Style priority:
inline style embedded style = = Link style (Nearest principle)
How to link and how to import different:
1. The CSS referenced by the link will be loaded at the same time. The introduction of the import of CSS in the page is loaded after the full load, in the slow speed of the Web page will appear without style situation. (Import method Mishap)
2, the link way supports the JavaScript to modify the style, but the import method does not support (import method mishap)
3, link the way import CSS any browser is OK, and import method requires browser version must be above IE5
Suggested use of link 3, CSS selector
*CSS selector: Specifies which HTML tag the CSS style acts on 3.1, element selector
* Just use the HTML tag name as the selector name
* Format: Tag name {} 3.2, class selector
* Style format:. Class Name {}
* Label format: <p class= "class name" ></p>
* can set different tags of the same style 3.3, ID selector (highest priority)
* Style format: #id名 {}
* Label format: <p id= "id name" ></p>
* Targeted settings style 3.4, attribute selector (worst browser compatibility)
* Select according to the attribute name and attribute value of the label signature and tag
* Style Format: Tag name [property name = ' attribute value '] 3.5, pseudo element selector (special)
*html pre-defined selectors
* Format: Tag name: selector {}
* The selector name is the status of the HTML tag. For example: a:link{} indicates that the link label is not accessed in an outdated style.
!important can refer to the highest priority level
For example: Color:red!important;
JavaScript Basics + Advanced 1, JavaScript Overview 1.1, what is JavaScript, what is the role?
*javascript is the most popular scripting language on the Internet.
* Scripting languages cannot be used alone and must be embedded in other languages combined with
JavaScript cannot be used alone and must be used in conjunction with other languages (HTML)
The *javascript is interpreted directly by the browser to perform without compiling (interpreting a piece, which executes a bar. So you can write code with a single statement do not use two statements)
The readability of chained programming is very poor.
To make a choice between readability and execution efficiency
* Function: Can control the logical operation of the front page
For example: JS can control the style of CSS;
JS can check the form items (Java EE focus)
JS enables dynamic control of HTML elements
Characteristics
Interactivity (JavaScript controls HTML elements)
Security (no access to System file permissions, can not be used to do severe trojan virus)
Cross-platform (browser with JS parser, as long as the browser can run JS code, and Platform-independent) 1.2, the composition of JavaScript
*ecmascript (CORE): Describes the syntax and basic objects of JS.
*dom Document Object Model: Methods and interfaces for working with Web page content
*bom Browser Object Model: Methods and interfaces for interacting with browsers 1.3, JavaScript and Java relationships
*javascript and Java do not have a relationship (Lei Feng and Leifeng Pagoda)
The difference between *javascript and Java:
>javascript code can be executed directly in the browser, and Java must be compiled before execution
>javascript is a weakly typed language, Java is a strongly typed language
Strongly typed language: requires that the use of variables strictly conforms to the definition. (for example, a variable is declared as an int type, and loading other types, such as a string type, will cause an error). Pain in programming, comfortable adjusting bugs
Weakly typed language: The use of variables is not required to strictly conform to the definition. (For example, you can store a number after a variable declaration, or you can store a string). Comfortable programming, pain when adjusting bugs
JavaScript Sample Code
<script>
var sum = 0;
for (var i = 1; i <=; i++) {
sum + = i;
}
alert (sum);
</script>
<body>
</body>
L Two ways of Use
> Internal Use
*<script type= code for "Text/javascript" >javascript </script>
> External References
*<script type= "Text/javascript" src= "javascript file path" ></script>
* External references cannot have script code within the script tag, even if it is not executed, it will be overwritten
Note that:<script> tags can be written anywhere, but be aware of the loading order of HTML and JavaScript
Extended:
If the JavaScript code doesn't use any HTML elements, you can place it anywhere
If the JavaScript code uses an HTML element, you must ensure that the HTML element is loaded first. 3, JavaScript syntax and use (emphasis) 3.1, comments
* Single-line comment
//
MyEclipse shortcut key Ctrl+shift+c
* Multi-line Comment
/* */
MyEclipse shortcut key ctrl+shift+/
Cancellation: ctrl+shift+\ 3.2, variable 3.2.1, variable description
* Mark a piece of space in memory for storing data, data is variable
Format
var variable name = variable value;
Variable declarations in JavaScript can be used with the VAR keyword (global variables are not declared with Var)
The data type of the variable is divided into: raw data type
Reference data type 3.2.2, raw data type
Similar to the basic data types in Java. (All values exist in the memory stack, fixed size, for quick check)
String
String type
"and" both represent strings
Boolean
Boolean type
True,false
Number
Number Type
Integers, decimals, and Nan (not a number)
Nan!=nan
Null
Empty, placeholder for object
An object that represents a reference type does not exist
Generally used for the abolition of objects. (That is, each time an object is not used, it is manually set to empty, at the end of the function or otherwise, the garbage collector collects it)
Undefined
value is not defined. That is, the declared variable is unassigned and the system is automatically assigned a value undefined
Use occurs when a variable declaration is not assigned a value when the property of the/object is not assigned undefined
Undefined is a default value
However, if the variable is not declared, JavaScript reports that the variable is undefined and stops the code.
For example: Alert (str);//javascript code stops parsing run at this line and throws the variable str undefined error
Undefined easy and variable not declared use confusion
Variable declaration not defined:
var str;
alert (str);//undefined
Variables that are not declared are used:
alert (AAACCC);//error, and truncation of JavaScript code
undefined==undefined
Note: Variables are like a plate, and everything can be dressed up.
The type of the variable value can be judged by typeof (). For example: Var str= "AA"; alert (typeof (str));//string
The casing of the variable is sensitive, and yy and yy are not a variable.
Why the TypeOf operator returns "Object" for null values. This is actually an error in the initial implementation of JavaScript, and is then used by ECMAScript. Now NULL is considered a placeholder for the object, explaining the contradiction, but technically it is still the original value.
Undefined is derived from null, so you null==undefined get a true result when you judge 3.2.3, reference data type
A reference type is often called a class (. Class), and a reference value is encountered, and the object is processed. But in the traditional sense, JavaScript does not have a real class.
For example: var obj = new Object ();//written by an engineer from Java
var obj = new object;//written by JS Engineer
Two upper and lower effects equivalent
Object definition: Created by the new keyword plus the name of the object to instantiate.
For example: var flag = new Boolean ("false");
Alert (flag);//true
Common objects:
String,number,boolean,array,date,math,regexp
Note: instanceof can be used to determine whether an object belongs to a type. Returns true and False. For example:
var str = new String ();
Alert (str instanceof String);//true
Alert (str instanceof Object);//true
Alert (str instanceof Array);//false 3.2.4, type conversion (the value of the original data type is turned out)
1. Convert to String
Boolean,string,number its original value is actually a pseudo-object, in JS there are boolean,string,number such objects, you can directly from the original value call its ToString () method to convert to a string.
For example:
var flag = true;
Alert (flag.tostring ());
var num = 10;
Alert (num.tostring ());
Generally not used in development, generally use the + operator plus a string form to convert the string.
For example: var num = 10;
Alert (num+ "");
2. Convert strings into numbers
parseint (string); Parses a string into a value of type number and returns the integer type (fractional part is not required)
If a character of string cannot be parsed to a number by literal value, then the character begins to be truncated.
If the first character of string cannot be resolved to number, then a nan is returned
Parsefloat (string); Parses a string into a value of type number and returns it by literal value, floating-point
If a character of string cannot be parsed to a number by literal value, then the character begins to be truncated.
If the first character of string cannot be resolved to number, then a nan is returned
3. Forced type conversion (learn)
Boolean (value)-converts the given value to a Boolean type;
True if value exists or is meaningful;
False if value does not exist or is meaningless.
Number-Converts the given value to a digit (which can be an integer or a floating point).
String: If the literal value can be parsed to a number, it is converted normally. Returns Nan if the literal has a character that cannot be resolved to a number
Boolean:true converted to 1,false to 0
Null: Switch to 0
Undefined: Convert to Nan
String (value)-converts the given value to a string by literal values;
The above three coercion type conversion methods, the returned values are the values of the original data type 3.3, the operator 3.3.1, the arithmetic operator
+ Symbols
L Arithmetic operations Plus (no strings appear, and other values are strongly converted to number types for addition operations)
L string Connector (one of which must be a string)
L number Strong turn (other type strong to number):
For example: var str = + "11";
Var str = number ("11");
The upper and lower two codes are completely equivalent
-Symbols
L arithmetic operations minus (the other values are strongly converted to number types for subtraction)
L number Strong turn (other type strong to number, different from +, are negative):
For example: var str =-"11";
Var str =-number ("11");
The upper and lower two codes are completely equivalent
, 3.3.2, Comparison operators (emphasis)
= = logic and so on. Compare values
= = = Congruent. Compare values and types. True if the value and type are the same; false if the value and type have a difference
! = range. Comparison value. Value is not the same as true. Same value false
!== not congruent. Compares a value or comparison type, False if the value and type are the same, or true if the value and type have a difference
Practice:
var x=8;
alert (x==8);
alert (x===8);
Alert (x== "8");
Alert (x=== "8");
alert (x!=8);
alert (x!=1);
alert (x!==8);
alert (x!==1);
Alert (x!= "8");
Alert (x!= "1");
Alert (x!== "8");
Alert (x!== "1"); 3.3.3, logical operators
&& Logic and
|| Logical OR
! Non -
The above logical operators in development are often used with an if statement.
Using the above logical operators in an if or other expression will eventually be a Boolean operation, or a strong turn if it is not a Boolean type.
Note: except! Alert is not supported outside
& is not included in the logical operator, and the & in JS is the bitwise operator 3.4, the Process Control statement
The expression of the process control of the program 3.4.1, Judgment statement (emphasis)
If statement
if (condition) {
}else{
}
Exercise: The following code outputs the result:
var a=15;
if (a=15) {
alert (15);
}else{
Alert ("Else");
}
A. 15
B. Else
1. If Inside a=15
2, A is assigned a value of 15
3. If (ÀIF)-----(true)
Note: If write = is assigned.
An IF condition assigns a value to the variable before assigning the value of the variable to a Boolean.
Bug debugging generally with Firebug can
Switch statement
Switch (n)
{
Case 1:
Executing code block 1
Break
Case 2:
Executing code block 2
Break
Default
If n is not 1 and not 2, execute this code
}
Switch compares the types of values and values (congruent comparison) 3.4.2, loop statements
Normal for loop: (Common)
for (Var i=0;i<=8;i++) {
Loop body
}
And the only difference in Java:
The var keyword for defining variables in JavaScript
For: In loop: (infrequently used)
Java-like enhancements for loops (but with essential differences)
For ... The in declaration is used to iterate over the properties of an array or an object.
The code for the for ... in loop executes once for each element of the array.
for (var variable in object or array) {
Loop body
}
Different from Java:
When iterating through an array, where the traversal variable represents the subscript (and attribute) of the array.
For example:
Array Traversal:
var p=[1,2,3];
for (var i in P) {
Alert ("Array subscript:" +i);
Alert ("array element:" +p[i]);
} 3.5, Object 3.5.1, Number object (Learn)
*var num = 10;//Pseudo-object, value is raw data type
*var num = new number (10);//value is a reference data type, if the construction parameter is omitted, the default is 0
*var num = number (10);//strong-turn, pseudo-object, value is the original data type
Number property:
ValueOf ()
Returns the base numeric value of a number object. 3.5.2, Boolean object (Learn)
*var flag = false;//Pseudo-Object
*var flag = new Boolean (false);
*var flag = Boolean (false);
Note: If the constructor omits a parameter, or is set to 0,-0, NULL, "", false, undefined, or NaN, the object is set to False. Otherwise set to true (even if the value parameter is the string "false"). 3.5.3, String Object
* var str = "abc";//Pseudo-Object
* var str = new String ("abc");//If omitted, the default is an empty string
*var str = String ("abc");
String property:
Length
The length of the string
String method:
CharAt (Index)
Returns the character at the specified position
Concat (Str1,str2,str3 ...)
Connection string and returns the result after the connection
IndexOf (Searchvalue,fromindex)
Retrieving strings
Replace (regexp,replacement)
Replace string
Only the first occurrence of the string can be replaced.
If you want to replace multiple occurrences of a string, use a regular.
For example:
Str.replace (/a/g, "f");//Replace all A for F
"There are two methods for replace and ReplaceAll in Java, and replace is an exercise method for replacing a single character, and ReplaceAll is a method of combining regular expressions in development to replace a specified regular character.
】
Split (separator)
Splits a string into arrays based on a delimiter
SUBSTR (Start,length)
Intercept string
From where to start, intercept the length
SUBSTRING (start,stop)
Intercept string
Where to start, where to combine (contains the beginning does not contain the end)
toLowerCase ()
Convert a string to lowercase
toUpperCase ()
Convert a string to uppercase
Note: None of the above methods will change the original string 3.5.4, array object (emphasis)
* JS Array Object
* var arr = [1,2,3];//array length is 3, elements are three-in-one
* var arr = new Array (), array length defaults to 0
* var arr = new Array (4); The array length is 4, which is equivalent to opening up a space of 4, each element being undefined. (processed only when the array is displayed, undefined is an empty string for display purposes, and its value is still undefined)
* var arr = new Array (UP); The array length is 2, and the array element is
Array property:
Length
The length of the array
*javascript and the difference between arrays in Java:
1, the length of the array is variable
2. Array elements can be any type
Exercise: The following code prints the result:
var arr1 = new Array (4);
arr1[10]=5;
alert (arr1.length);
A.4
b.10
c.11
d.undefined
var arr1 = new Array (4);
arr1[10]=5;//arr1[4]=undefined;arr[5]=undefined...arr[9]=undefined;
alert (arr1.length);
Think: The following code prints the results in turn:
var arr1 = new Array ();
arr1[1]=10;//arr[0]=undefined; The length is 2.
arr1["Name"]= "Jerry";
for (Var i=0;i<arr1.length;i++) {
Alert (Arr1[i]);
}
a.undefined,10
b.10
C.10,name
D.undefined,10,name
Note: arr1["key"]=value; This form will no longer be added as an element of an array, but as an attribute of an array object. Therefore, the length can only count the number of elements, not statistical properties. You can use the for: In loop can be removed
Array method
Concat (Arr1,arr2,arr3 ...)
Joins two or more arrays and returns the result after the connection.
Has no effect on the called array.
Join (delimiter)
Convert to String return
Has no effect on the called array.
Pop ()
Delete and return the last element of the array
If the array is already empty, the pop () does not change the array and returns the undefined value
Shift ()
Delete and return the first element of the array
If the array is empty, then the shift () method will not take any action, returning the undefined value
Push (Element1,element2,.....)
Adds one or more elements to the end of the array and returns the new length of the array
Unshift (Element1,element2,.....)
Adds one or more elements to the beginning of the array and returns the new length of the array
Not recommended because some browsers are not compatible with this method
Reverse ()
Reverses the order of the elements in the array. Physical rollover
Sort (optional sort function)
Sorting elements of an array
Example of a sort implementation:
function Sortnumber (A, B)
{
Return A-B
} 3.5.5, Date object
* var date = new Date (); Current system time (local time)
* var date = new Date (millisecond value), set time
Date method
toLocaleString ()
Convert to a string based on a local date format
GetDate ()
Returns one day in one months
GetDay ()
Return one day of the week (0-6) 0 for Sunday
GetMonth ()
Get month (0-11) 0 for January
getFullYear ()
Get year
GetTime ()
Gets the number of milliseconds
SetTime ()
Set the date by the number of milliseconds
Parse (datestring)
Parse string, returns the number of milliseconds
Date.parse ("2005/12/31 17:07:07");
Date.parse ("2005/12/31");
Date.parse ("7/8/2013 17:07:07");
Date.parse ("Jul 8,2011 17:07:03");
Date.parse ("2012-12-31t07:07:07"); IE10 support job: Emptying all elements in the array
<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML> <Head> <title>Homework.html</title> <Metahttp-equiv= "keywords"content= "Keyword1,keyword2,keyword3"> <Metahttp-equiv= "description"content= "This is my page"> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"> <!--<link rel= "stylesheet" type= "Text/css" href= "./styles.css" > - </Head> <Scripttype= "Text/javascript"> vararr=[1,2,3,4]; while(Arr.length!=0) {arr.shift (); } alert (arr); </Script> <Body> </Body></HTML>
JAVA Web day02---Android small white the next day to study notes