CSS Learning notes (1)

Source: Internet
Author: User

Why to re-learn CSS, for a lot of reasons, CSS this little chick hit, contact so far has been three years, but really said proficiency is not necessarily. Hereby, for my goal to begin to rearrange the knowledge of CSS, I hope that every note can have an example to consolidate my knowledge.

At the beginning of the study, the first introduction we just will play less, for like my memory super poor people, have a better CSS document is just a dream ah, the recent project to do a home page, seven sub-pages, the most critical is the sub-page details are not the same, not the structure, but the font, spacing, color, Design to the prototype said to be a bright color, accurate, and not the same as before Bai, no language le, hereby learn less, online generation http://www.lesscss.net/#online-less-compilers, of course, I use sublime There are plugins directly generated OH



@link-success: #00CC33 #a:link {@link-success} ;--less#a:link {#00CC33} ;--css

Since a variable can only be defined once, its essence is "constant". For me, if a color is defined more than three times, but is a different level, you can use {class}

But look at the egg pain, want to want to change one, I either rewrite a class to overwrite, or modify the original? (WebApp font changed many times a day) for me, using less to define a new variable, and then put it in less, the key level is clear;


@nav: Nav; [Email protected] {nav} {     font-weight: bold; line-height: 40px; margin: 0 auto;    } --less

Pay attention to the wording, then I now add a bottom nav, so easy

[email protected] {nav}    { font-weight: bold; line-height: 40px; margin: 0 auto;    } --less

(3) @var: @a;@a: %;

. Lazy-eval-scope {width: @var; @a: 9;} --less

Repeated reference to chant, but this does not have to write directly fast, have to think good hierarchical relationship, for the General page, I think the above two basic enough, especially cross-browser Webkit,moz, write dead, I never diligent, but love toss, with less save most of the work of CTRL + C, more critical, Not modular, it doesn't sound low.


(1) Plug the other class,id directly in

. Border-small {Border:1px solid #00CC33} . Topnav {width:80%,.border-small} ;--less.topnav {width:80%,border:1px solid #00CC33} ;--css

I would like to mix, but it is best to split it with the call layer, in addition, add a comment chant, old forget.

(2) using CSS selector notation

{  . Inner {    color: red;  }  {  #outer >. inner;}  {  . Inner () {    color: red;  }  {  #outer >. inner;}  {  color: red;}

So, if you want to hide, if you do not want its class to appear, but also useful, after the class name plus (). There's important in the mix. You need to be aware that you can do this directly by assigning values

{ background: @bg; color: @color; }{}{}
{ color: black; . Navigation {font-size: 12px;}  { width: 300px;}  {  color: black;}  {  font-size: 12px;}  {  width: 300px;}


This is very useful for me, I can put some common constants are encapsulated in a less file, when used only in the new less file to be introduced in the good.

Of course, this is just my way of managing CSS documents, used to treat my intermittent amnesia, and I've been reading CSS recently, and I'm thinking, by re-learning, to start making components of my own work. fighting!

CSS Learning notes (1)

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.