ÀÖÓãµç¾º

  • ½ÌÓýÐÐÒµA¹ÉIPOµÚÒ»¹É£¨¹ÉƱ´úÂë 003032£©

    È«¹ú×Éѯ/ͶËßÈÈÏߣº400-618-4000

    Webǰ¶Ë¿ª·¢Åàѵ֮20¸öºÜÓÐÓõÄCSS¼¼ÇÉ

    ¸üÐÂʱ¼ä:2016Äê11ÔÂ23ÈÕ14ʱ42·Ö À´Ô´:ÀÖÓã²¥¿Íwebǰ¶Ë¿ª·¢ÅàѵѧԺ ä¯ÀÀ´ÎÊý:

    ÏÂÃæÕ⼸¸öCSS¼¼ÇÉÄã¿ÉÄܲ»ÖªµÀ£¬1.²ÊÉ«ÕÕÆ¬±äºÚ°×£¬2.ËùÓÐÔªËØ´¹Ö±¾ÓÖУ¬3.½ûÓÃÊó±ê£¬4.Ä£ºýÎÄ×Ö£¬Ð¡±àѧÍêÄÜÁ¿ÂúÂúµÄ£¬¾õµÃ¶ÔCSSÓÖ³äÂúÁ˰®£¬ÄãÒ²À´¿´¿´¡£
    1. ºÚ°×ͼÏñ
    Õâ¶Î´úÂë»áÈÃÄãµÄ²ÊÉ«ÕÕÆ¬ÏÔʾΪºÚ°×ÕÕÆ¬£¬ÊDz»ÊǺܿ᣿
    img.desaturate {    filter: grayscale(100%);    -webkit-filter: grayscale(100%);    -moz-filter: grayscale(100%);    -ms-filter: grayscale(100%);    -o-filter: grayscale(100%);}
    2. ʹÓà :not() Ôڲ˵¥ÉÏÓ¦ÓÃ/È¡ÏûÓ¦Óñ߿ò
    ÏȸøÃ¿Ò»¸ö²Ëµ¥ÏîÌí¼Ó±ß¿ò
    /* add border */.nav li {  border-right: 1px solid #666;}
    ……È»ºóÔÙ³ýÈ¥×îºóÒ»¸öÔªËØ……
    // remove border /.nav li:last-child {  border-right: none;}
    ……¿ÉÒÔÖ±½ÓʹÓà :not() αÀàÀ´Ó¦ÓÃÔªËØ£º
    .nav li:not(:last-child) {  border-right: 1px solid #666;}
    ÕâÑù´úÂë¾Í¸É¾»£¬Ò×¶Á£¬Ò×ÓÚÀí½âÁË¡£
    µ±È»£¬Èç¹ûÄãµÄÐÂÔªËØÓÐÐÖµÜÔªËØµÄ»°£¬Ò²¿ÉÒÔʹÓÃͨÓõÄÐÖµÜÑ¡Ôñ·û£¨~£©£º
    ..nav li:first-child ~ li {  border-left: 1px solid #666;}

    3. Ò³Ãæ¶¥²¿ÒõÓ°
    ÏÂÃæÕâ¸ö¼òµ¥µÄ css3 ´úÂëÆ¬¶Î¿ÉÒÔ¸øÍøÒ³¼ÓÉÏÆ¯ÁÁµÄ¶¥²¿ÒõӰЧ¹û£º
    body:before {          content: "";          position: fixed;          top: -10px;          left: 0;          width: 100%;          height: 10px;           -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);          -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);          box-shadow: 0px 0px 10px rgba(0,0,0,.8);           z-index: 100;}

    4. ¸ø body Ìí¼ÓÐиß
    Äã²»ÐèÒª·Ö±ðÌí¼Ó line-height µ½Ã¿¸öp,h±ê¼ÇµÈ¡£Ö»ÒªÌí¼Óµ½ body ¼´¿É£º
    body {  line-height: 1;}
    ÕâÑùÎı¾ÔªËؾͿÉÒÔºÜÈÝÒ×µØ´Ó body ¼Ì³Ð¡£
    5. ËùÓÐÒ»Çж¼´¹Ö±¾ÓÖÐ
    Òª½«ËùÓÐÔªËØ´¹Ö±¾ÓÖУ¬Ì«¼òµ¥ÁË£º
    html, body {  height: 100%;  margin: 0;}body {  -webkit-align-items: center;    -ms-flex-align: center;    align-items: center;  display: -webkit-flex;  display: flex;}
    ¿´£¬ÊDz»ÊǺܼòµ¥¡£
    ×¢Ò⣺ÔÚIE11ÖÐҪСÐÄflexbox¡£
    6. ¶ººÅ·Ö¸ôµÄÁбí
    ÈÃhtmlÁбíÏî¿´ÉÏÈ¥ÏñÒ»¸öÕæÕýµÄ£¬ÓöººÅ·Ö¸ôµÄÁбí£º
    ul > li:not(:last-child)::after {  content: ",";}
    ¶Ô×îºóÒ»¸öÁбíÏîʹÓà :not() αÀà¡£
    7. ʹÓøºµÄ nth-child Ñ¡ÔñÏîÄ¿
    ÔÚCSSÖÐʹÓøºµÄ nth-child Ñ¡ÔñÏîÄ¿1µ½ÏîÄ¿n¡£
    li {  display: none;}/* select items 1 through 3 and display them */li:nth-child(-n+3) {  display: block;}

    8. ¶Ôͼ±êʹÓà SVG
    ÎÒÃÇûÓÐÀíÓɲ»¶Ôͼ±êʹÓÃSVG£º
    .logo {  background: url(/news/20161123/"logo.svg");}
    SVG¶ÔËùÓеķֱæÂÊÀàÐͶ¼¾ßÓÐÁ¼ºÃµÄÀ©Õ¹ÐÔ£¬²¢Ö§³ÖËùÓÐä¯ÀÀÆ÷¶¼»Ø¹éµ½IE9¡£ÕâÑù¿ÉÒԱܿª.png¡¢.jpg»ò.gifÎļþÁË¡£
    9. ÓÅ»¯ÏÔʾÎı¾
    ÓÐʱ£¬×ÖÌå²¢²»ÄÜÔÚËùÓÐÉ豸É϶¼´ïµ½×î¼ÑµÄÏÔʾ£¬ËùÒÔ¿ÉÒÔÈÃÉ豸ä¯ÀÀÆ÷À´°ïÖúÄ㣺
    html {  -moz-osx-font-smoothing: grayscale;  -webkit-font-smoothing: antialiased;  text-rendering: optimizeLegibility;}
    ×¢£ºÇ븺ÔðÈεØÊ¹Óà optimizeLegibility¡£´ËÍ⣬IE /EdgeûÓÐ text-rendering Ö§³Ö¡£
    10. ¶Ô´¿ CSS »¬¿éʹÓà max-height
    ʹÓàmax-height ºÍÒç³öÒþ²ØÀ´ÊµÏÖÖ»ÓÐCSSµÄ»¬¿é£º
    .slider ul {  max-height: 0;  overlow: hidden;}.slider:hover ul {  max-height: 1000px;  transition: .3s ease;}

    11. ¼Ì³Ð box-sizing
    Èàbox-sizing ¼Ì³Ð html£º
    html {  box-sizing: border-box;}*, *:before, *:after {  box-sizing: inherit;}
    ÕâÑùÔÚ²å¼þ»ò¸Ü¸ËÆäËûÐÐΪµÄÆäËû×é¼þÖоÍÄܸüÈÝÒ׵ظıä box-sizing ÁË¡£
    12. ±í¸ñµ¥Ôª¸ñµÈ¿í
    ±í¸ñ¹¤×÷ÆðÀ´ºÜÂé·³£¬ËùÒÔÎñ±Ø¾¡Á¿Ê¹Óàtable-layout: fixed À´±£³Öµ¥Ôª¸ñµÄµÈ¿í£º
    .calendar {  table-layout: fixed;}

    13. Óà Flexbox °ÚÍÑÍâ±ß¾àµÄ¸÷ÖÖ hack
    µ±ÐèÒªÓõ½Áзָô·ûʱ£¬Í¨¹ýflexboxµÄ space-between ÊôÐÔ£¬Äã¾Í¿ÉÒÔ°ÚÍÑnth-£¬first-£¬ºÍ last-child µÄhackÁË£º
    .list {  display: flex;  justify-content: space-between;}.list .person {  flex-basis: 23%;}
    ÏÖÔÚ£¬Áбí·Ö¸ô·û¾Í»áÔÚ¾ùÔȼä¸ôµÄλÖóöÏÖ¡£
    14. ʹÓÃÊôÐÔÑ¡ÔñÆ÷ÓÃÓÚ¿ÕÁ´½Ó
    µ±aÔªËØÃ»ÓÐÎı¾Öµ£¬µ« href ÊôÐÔÓÐÁ´½ÓµÄʱºòÏÔʾÁ´½Ó£º
    a[href^="http"]:empty::before {  content: attr(href);}
    Ï൱·½±ã¡£
    webǰ¶Ë¿ª·¢Åàѵ
    15. ¼ì²âÊó±êË«»÷
    HTML£º
    <div class="test3">  <span><input type="text" value=" " readonly="true" />  <a href="http://renpingjun.com">Double click me</a></span></div>
    CSS£º
    .test3 span {  position: relative;}.test3 span a {  position: relative;  z-index: 2;}.test3 span a:hover, .test3 span a:active {  z-index: 4;}.test3 span input {  background: transparent;  border: 0;  cursor: pointer;  position: absolute;  top: -1px;  left: 0;  width: 101%;  /* Hacky */  height: 301%; /* Hacky */  z-index: 3;}.test3 span input:focus {  background: transparent;  border: 0;  z-index: 1;}

    16. CSS д³öÈý½ÇÐÎ
    ÀûÓÃborderÀ´Ð´Èý½ÇÐδúÂ룬²¢ÇÒ¼æÈÝIE6.
    /* create an arrow that points up */div.arrow-up {  width:0px;  height:0px;  border-left:5px solid transparent;  /* left arrow slant */  border-right:5px solid transparent; /* right arrow slant */  border-bottom:5px solid #2f2f2f; /* bottom, add background color here */  font-size:0px;  line-height:0px;} /* create an arrow that points down */div.arrow-down {  width:0px;  height:0px;  border-left:5px solid transparent;  border-right:5px solid transparent;  border-top:5px solid #2f2f2f;  font-size:0px;  line-height:0px;} /* create an arrow that points left */div.arrow-left {  width:0px;  height:0px;  border-bottom:5px solid transparent;  /* left arrow slant */  border-top:5px solid transparent; /* right arrow slant */  border-right:5px solid #2f2f2f; /* bottom, add background color here */  font-size:0px;  line-height:0px;} /* create an arrow that points right */div.arrow-right {  width:0px;  height:0px;  border-bottom:5px solid transparent;  /* left arrow slant */  border-top:5px solid transparent; /* right arrow slant */  border-left:5px solid #2f2f2f; /* bottom, add background color here */  font-size:0px;  line-height:0px;}

    17. CSS3 calc() µÄʹÓÃ
    calc() Ó÷¨ÀàËÆÓÚº¯Êý£¬Äܹ»¸øÔªËØÉèÖö¯Ì¬µÄÖµ£º
    /* basic calc */.simpleBlock {  width: calc(100% - 100px);} /* calc in calc */.complexBlock {  width: calc(100% - 50% / 3);  padding: 5px calc(3% - 2px);  margin-left: calc(10% + 10px);}

    18. Îı¾½¥±ä
    Îı¾½¥±äЧ¹ûºÜÁ÷ÐУ¬Ê¹Óà CSS3 Äܹ»ºÜ¼òµ¥¾ÍʵÏÖ£º
    h2[data-text] {  position: relative;}h2[data-text]::after {  content: attr(data-text);  z-index: 10;  color: #e3e3e3;  position: absolute;  top: 0;  left: 0;  -webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0)), color-stop(50%, rgba(0,0,0,1)), to(rgba(0,0,0,0)));}

    19. ½ûÓÃÊó±êʼþ
    CSS3 ÐÂÔöµÄ pointer-events ÈÃÄãÄܹ»½ûÓÃÔªËØµÄÊó±êʼþ£¬ÀýÈ磬һ¸öÁ¬½ÓÈç¹ûÉèÖÃÁËÏÂÃæµÄÑùʽ¾ÍÎÞ·¨µã»÷ÁË¡£
    .disabled { pointer-events: none; }

    20. Ä£ºýÎı¾
    ¼òµ¥µ«ºÜƯÁÁµÄÎı¾Ä£ºýЧ¹û£¬¼òµ¥Óֺÿ´£¡
    .blur {   color: transparent;   text-shadow: 0 0 5px rgba(0,0,0,0.5);}

    ±¾ÎİæÈ¨¹éÀÖÓã²¥¿Íwebǰ¶Ë¿ª·¢Ñ§ÔºËùÓУ¬»¶Ó­×ªÔØ£¬×ªÔØÇë×¢Ã÷×÷Õß³ö´¦£¬Ð»Ð»£¡
    ×÷ÕߣºÀÖÓã²¥¿Íwebǰ¶ËÅàѵѧԺ£»
    Ê×·¢£ºhttp://www.itcast.cn/web/

    0 ·ÖÏíµ½£º
    ºÍÎÒÃÇÔÚÏß½»Ì¸£¡
    ¡¾ÍøÕ¾µØÍ¼¡¿¡¾sitemap¡¿