[关闭]
@15013890200 2018-10-12T18:44:04.000000Z 字数 4265 阅读 470

css学习实践

css

前面一节补充了css一些薄弱的知识点。今天集中实践了不少。感觉收获还是蛮多的(平时对css忽略蛮多的,只写了一些基本样式)。
本次主要实践了 display的sticky属性、伪类/伪节点、文本处理、图片处理


  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>usefulCss</title>
  6. <style type="text/css">
  7. .div_container{}
  8. .div_container div{height: 200px;border: 1px solid #ddd;margin-bottom: 20px;text-align: center;align-items: center;display: flex;justify-content: center;}
  9. .div_container div:nth-child(2){background-color: #ddd;position: sticky;top: 0;width: 100%;z-index: 100;}
  10. .div_container div:nth-child(2)+div{font-size: 20px;font-weight: bold;color: rgba(255,0,0,0.5);cursor: pointer;}
  11. .div_container div:nth-child(2)~div{border-radius: 5px;transition: box-shadow 0.3s;}
  12. .div_container div:nth-child(2)~div:hover{box-shadow: 0 0 15px 1px #ddd,0 0 8px 0 rgba(255,0,0,0.3) ;margin-top: -1px;}
  13. .div_container div:nth-child(4){transform: scale(0.5,0.5);}
  14. .div_container div:nth-child(5){transform: rotate(3deg);}
  15. .div_container div:nth-child(6){transform: translate(50%,0);}
  16. .div_container div:nth-child(7){transform: skew(50deg,0deg);}
  17. .a{text-decoration: none;}
  18. .a:link{font-size: 18px;}
  19. .a:hover{text-decoration:underline;}
  20. .a:visited{color: #bbb;cursor: not-allowed!important;}
  21. .a:active{color: #3896fe;}
  22. .div_checkbox{margin: 20px;user-select: none;}
  23. .div_checkbox label{cursor: pointer;color: #000;}
  24. .div_checkbox input{cursor: pointer;}
  25. .div_checkbox input:checked+span{color: #3896f8;transition: color 0.3s;}
  26. .div_checkbox input:disabled~span{color: #bbb;cursor: not-allowed;}
  27. .div_radio{margin: 20px;user-select: none;}
  28. .div_radio span{position: relative;top: -2px;cursor: pointer;}
  29. .div_radio input{cursor: pointer;}
  30. .div_radio input:checked+span{color: red;}
  31. .div_words>p{margin: 20px;width: 200px;text-transform: capitalize;letter-spacing: 0;word-spacing: 2px;}
  32. .div_words p:nth-child(2):first-line{color: red;}
  33. .div_words p:nth-child(2){text-indent: 32px;}
  34. .div_words p:nth-child(1):first-letter{font-size: 30px;font-weight: bold;float: left;}
  35. /** 多行文本省略 **/
  36. .div_words2{margin: 20px;width: 200px;display: -webkit-box;-webkit-box-orient:vertical;text-overflow: ellipsis;overflow: hidden;-webkit-line-clamp:3;}
  37. .div_imgs img{width: 200px;height: 100px;margin: 10px;transition: filter 0.1s;}
  38. .div_imgs img:nth-child(1){filter: blur(5px);}
  39. .div_imgs img:nth-child(2){filter: grayscale(100%);}
  40. .div_imgs img:nth-child(3){filter: opacity(50%);}
  41. .div_imgs img:nth-child(4){filter: invert(100%);}
  42. .div_imgs img:nth-child(5){filter: saturate(7);}
  43. .div_imgs img:hover{filter: none;}
  44. </style>
  45. </head>
  46. <body>
  47. <div class="div_container">
  48. </div>
  49. <a href="#b" class="a">bbb</a>
  50. <div class="div_checkbox">
  51. <label><input type="checkbox" name="friuts" value="apple"><span>apple</span></label>
  52. <label><input type="checkbox" name="friuts" value="orange"><span>orange</span></label>
  53. <label><input type="checkbox" name="friuts" value="banana" disabled><span>banana</span></label>
  54. </div>
  55. <div class="div_radio">
  56. <label><input type="radio" name="animals" value="dog"><span>dog</span></label>
  57. <label><input type="radio" name="animals" value="pig"><span>pig</span></label>
  58. <label><input type="radio" name="animals" value="cat"><span>cat</span></label>
  59. </div>
  60. <div class="div_words">
  61. <p>端请求携带必要设备和广告位等信息,接口根据广告位id查找该广告位正在投放的广告信息,再根据条件过滤,选取最符合条件的广告信息。然后判断该广告是否来源于dsp,如果是,则向dsp方请求最新广告素材信息;如果不是,则按照原有逻辑处理。</p>
  62. <p>my name is hhhhh eujhtiuerht heg iewjht</p>
  63. </div>
  64. <div class="div_words2">
  65. 端请求携带必要设备和广告位等信息,接口根据广告位id查找该广告位正在投放的广告信息,再根据条件过滤,选取最符合条件的广告信息。然后判断该广告是否来源于dsp,如果是,则向dsp方请求最新广告素材信息;如果不是,则按照原有逻辑处理。
  66. </div>
  67. <div class="div_imgs">
  68. <img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
  69. <img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
  70. <img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
  71. <img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
  72. <img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
  73. </div>
  74. <script type="text/javascript">
  75. var container = document.querySelector('.div_container');
  76. function createItems(n){
  77. var html = '';
  78. for(var i = 0; i < n; i++){
  79. html += '<div>'+(i+1)+'</div>';
  80. }
  81. container.innerHTML = html;
  82. }
  83. createItems(10);
  84. container.addEventListener('click',getClick,true)
  85. function getClick(e){
  86. var ele = e.target;
  87. if(ele.children.length){
  88. console.log('i click the parent')
  89. }
  90. else{
  91. console.log('i click the child'+ele.innerText)
  92. }
  93. if(ele.innerText == 2){
  94. container.removeEventListener(container,getClick);
  95. }
  96. }
  97. </script>
  98. </body>
  99. </html>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注