csscode 2019-06-28
webkit
内核,其他内核自行查询.line { height: 1px; width: 100%; transform: scaleY(0.4); -webkit-transform: scaleY(0.4); background-image: linear-gradient(to right, #ccc 0%, #ccc 50%, transparent 50%); background-size: 4px 1px; background-repeat: repeat-x; }
<div class='line'></div>
background-size
值控制密度展示.article{ position: relative; } .mask{ position: absolute; width:100%; bottom:0; left: 0; height: 60px; background: linear-gradient(top, rgba(255,255,255,0), #fff); background: -webkit-linear-gradient(top, rgba(255,255,255,0), #fff); }
<div class="article"> 春眠不觉晓<br /> 处处闻啼鸟<br /> 夜来风雨声<br /> 花落知多少 <div class="mask"></div> </div>
div.mask
隐藏window.onload = function(){ document.getElementById('modalBtn').onclick = function (){switchModalStatus(true)}; document.getElementById('modal').onclick = function (){switchModalStatus(false)}; } function switchModalStatus(needShow){ var modal = document.getElementById('modal'); if(needShow){ modal.style.display = 'block'; disableBodyScroll(); }else{ modal.style.display = 'none'; enableBodyScroll(); } } function disableBodyScroll() { var body = document.body; window.stTemp = Math.max(body.scrollTop, document.documentElement.scrollTop); body.style.overflow = "hidden"; body.style.position = "fixed"; body.style.top = (-window.stTemp+'px'); } function enableBodyScroll() { var body = document.body; body.style.overflow = "scroll"; body.style.position = "static"; body.style.top = '0px'; body.scrollTop = window.stTemp; document.documentElement.scrollTop = window.stTemp; }
.modal{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, .5); z-index: 1; } .modal > .content{ position: absolute; top: 50%; left: 50%; transform: translateX(-50%) translateY(-50%); -webkit-transform: translateX(-50%) translateY(-50%); padding: 10px; width: 50%; background: white; border-radius: 12px; }
<button id="modalBtn">点我弹窗</button> <div id="modal" class="modal" style="display:none"> <div class="content">我是弹窗</div> </div>
.text { text-align: left; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }
<p class="text">我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容我有很多内容</p>
-webkit-line-clamp
控制显示的行数