Saturday, August 9, 2014

selector1 selector2. For example, we want to p are only within the elements with a class .happy-con


Also, the style includes the size and pazytsyyanavanne. Deliver our element height (height) equal to 200px and fix pazatsyyu fixed. header {height: 200px; position: fixed; background-color: yellow; cgpersia }
In the example above, we explain cgpersia the structure of the style. header - this selektar (selector). Browser selects the padpayuchyya under selector (here all the header on the page), apply the properties in the curly brackets {}. height - this property, 200px - is a property value. Connect css
First. Tag style - is in the head of the page. Immediately on the example of <html> <head> <style> div {background: yellow; height: 200px; } </ Style> </ head> <body> <div> </ div> <div> </ div> <body> </ html>
Other. Inline style. In html element has an attribute style, in which we can write the style of "in-place". Selectors, of course not necessary. Eg. <Body> <div style = "background: yellow; height: 200px;"> <div style = "background: yellow; height: 200px;"> </ body>
Well? Good or bad? Despite the fact that we should not bathe with selectors - just words on site. Got 2 bold cons - dubbed our code, absolutely lost in semantics, which are a class selector. The result - a bad way.
Third. The correct way. Separate file css. Create a file, for example style.css, we write our css there and connect it to our html page. Contents of the file style.css div {background: yellow; height: 200px; }
And how to connect to our web link tag with two attributes rel (file type) and href (file path) <html> <head> <link rel = "stylesheet" href = "style.css"> </ head> <body > <div> </ div> <div> </ div> </ body> </ html>
Excellent. Can write 1 time style, and connect to the 10-page file. For convenience, css files are located cgpersia in the css (respectively, do not forget to change the path to the file. Href = "css / style.css") types of selectors.
What is the difference selectors header, .warning-section, #sidebar? First. header - a selector tag. Want to select elements for tags to apply the properties. Members selector tags. header {background: yellow;} p {background: blue} div {background: red; } Section {background: green;}
Result. All elements cgpersia of the header will be - yellow, paragraphs p - blue, etc. That is, under the tag selector fallen all the tags, right? And how to choose the elements more selectively? For example, we want to only 1 or 2 section were red and the other not?
We write the html code. Will be 5 sections and only 2 will be red. Add class required html element. <Body> <section> I'm normal section </ section> <section class = "warning-section"> I'm cgpersia danger section </ section> <section> I'm normal section </ section> <section> I 'm normal section </ section> <section class = "warning-section"> cgpersia I'm danger section </ section> </ body>
Third. #sidebar - identsifikatar selector (id). Under the id selector will fall only 1 element on the page. Because identsifikatar not be repeated on the page. Write the following css #sidebar {background: blue; }
Ie id selector choose when we want to apply the properties of only one element on the page. The same can be achieved and the class (class simply add a single element). Apply a class or id - you decide. Opportunities selectors cgpersia
selector1 selector2. For example, we want to p are only within the elements with a class .happy-container, steel zhovtsenkimi. cgpersia To do this, put the problems between the selectors, as follows. .happy-container p {background: yellow; }
The following paragraphs will zhovtsenkiya html only within .happy-container. Write html. <Section class = "happy-container"> <p> happy paragraph </ p> <p> happy paragraph </ p> <div> <p> happy paragraph <p> </ div> </ section> cgpersia
selector1 + selector2. Neighbors. cgpersia Properties prymenyatstsa only element neighbor. Homework. Make selector consisting of 7 selectors (tags, classes, id) and use a space,>, and +. Zaverstats / parse layout. Determine the course projects: find the layout (image) for yourself and start miles. The first can find fashionable design on dryble, vkontakte second to know freelance exchanges https://www.odesk.com/o/jobs/browse/?q=psd+to+html cgpersia http://www.freelancer.com/ jobs / PSD-to-HTML / 3. Search for friends.


No comments:

Post a Comment