css代碼整理、收集

來源:互聯網
上載者:User

標籤:style   blog   http   color   java   os   strong   io   

整理了一下之前用到過的css代碼,實現一種效果或許有許多種寫法,我這裡整理了一下我個人認為相容性比較好,結構比較簡潔的代碼……如有寫得不對的地方敬請前輩們指點賜教一下,小弟不勝感激!此學習筆記是動態——我日後發現有好的程式碼片段會陸陸續續整理添加上去。

 

css:ellipsis省略符號

<style>.news{width:320px; text-overflow:ellipsis; -o-text-overflow:ellipsis; -moz-binding:url(‘ellipsis.xml#ellipsis‘); -ms-text-overflow:ellipsis; -webkit-text-overflow:ellipsis; overflow:hidden;}.news a{white-space:nowrap;}</style>  
<div class="news"> <a href="javascript:void(0);">你好,我是個css省略符號,支援各種瀏覽器,包括大IE6</a> <a href="javascript:void(0);">你好,我是個css省略符號,支援各種瀏覽器,包括大IE6</a></div>

 

滑鼠移過去圖片慢慢變暗(亮)一點

也就是用到了透明(opacity),漸層(transition)實現,如下是變暗的情況:

<style>.link_img{display:inline-block; width:auto; height:auto;}.link_img:hover{  background-color:#000;}.link_img:hover img{ display:block; filter:alpha(opacity=80); opacity:0.8; transition:all 0.5s ease-out; -webkit-transition:all 0.5s ease-out; -moz-transition:all 0.5s ease-out; -o-transition:all 0.5s ease-out;}</style>
<a href="javascript:void(0);" class="link_img"><img src="images/zy_19.jpg" /></a><a href="javascript:void(0);" class="link_img"><img src="images/pro3.jpg" /></a>

 

css:border實現的三角形

如要實現汽包,如新浪微博裡的,新浪裡用到的是的是特殊字元“◆”,,能實現相容到IE6,html代碼結構上不簡潔了,在html裡要多寫了class為”WB_arrow“的一層代碼,

要簡潔點,只能用border與偽類before,after了,附代碼如下:

 View Code

 

運行結果如:

IE6的:

但是用偽類before,after的border在大IE6裡不能做出三角形來,如要相容IE6還得用新浪裡的方法,或者用與新浪的相似,不過不是用特殊字元,而是也是用border做三角形,如下:

 1 <style> 2 .dome{width:300px; padding:30px 20px; border:1px solid #beceeb; position:relative;} 3 .dome .triangle{ position:absolute; bottom:0px; left:50px;} 4 .dome .triangle .bot{ 5     _display:block; 6     _line-height:0px; 7     border-width:20px; 8     border-style:solid dashed dashed dashed;  9     border-color:#beceeb transparent transparent transparent;10     position:absolute;11     bottom:-40px;12 }13 .dome .triangle .top{14     _display:block;15     _line-height:0px;16     border-width:20px; 17     border-style:solid dashed  dashed dashed; 18     border-color:#FFF transparent transparent transparent;19     position:absolute;20     bottom:-39px; 21 }  22 </style>23 24 <div class="dome">25   <div class="triangle">26       <em class="bot"></em>27       <em class="top"></em>28   </div>29   <div class="txtBox">30      我是用border實現的三角形,html結構上跟新浪微博上的結構相似31   </div>32 </div>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.