HTML5/CSS3實現添加鎖屏效果,html5css3實現鎖屏

來源:互聯網
上載者:User

HTML5/CSS3實現添加鎖屏效果,html5css3實現鎖屏
 鎖屏效果,也就是將螢幕置於模態,不允許使用者觸發任何動作,只能解除鎖定後才能繼續使用,jQueryUI的dialog有模態對話方塊,這一點不難做到。那麼,首先需要在頁面中添加一個div層,用於做模態的層: 
Html代碼  

  1. <div id="overlay">  

    其對應的CSS比較簡單,主要設定一下z-index屬性,值設定的很大即可,就能達到覆蓋其餘元素的效果,加上opacity淡化一下背景: 
Css代碼  
  1. #overlay{  
  2.     height:100%;  
  3.     min-width:1280px;  
  4.     width:100%;  
  5.     position:absolute;  
  6.     left:0px;  
  7.     top:0px;  
  8.       
  9.     opacity:0.7;  
  10.         z-index:100;  
  11. }  

    這樣就有了一個覆蓋頁面之上的層,顯示效果為: 
 
    下面是添加解除鎖定的部分,我們模仿iphone解鎖效果,那麼需要添加一下: 
Html代碼  
  1. <div id="slide">  
  2.     <span id="slider"></span>  
  3.     <span id="text">滑動解除鎖定</span>  
  4. </div>  

    一個圓角矩形框,左側是按鈕圖片,給出一個提示資訊,難度不大: 
Css代碼  
  1. #slide{  
  2.     position:absolute;  
  3.     top:75%;  
  4.     width:52%;  
  5.     left:24%;  
  6.     height:86px;  
  7.     border-radius:18px;  
  8.     border:1px solid #2F368F;  
  9.     border-bottom:1px groovy #2F368F;  
  10.     z-index:101;  
  11.     background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #2F368F),color-stop(1, #77D1F6));   
  12.     opacity:0.9;  
  13. }  

    這裡設定的z-index要比模態層大,這樣我們才能操控到,沒什麼多說的。 
Css代碼  
  1. #slider{  
  2.     float:left;  
  3.     position:relative;  
  4.     cursor:pointer;  
  5.     height:44px;  
  6.     background: url(../images/arrow.png) no-repeat;  
  7.     border-radius:16px;  
  8.     margin:-5px;  
  9.     text-align:center;  
  10.     width: 146px;  
  11.     height: 98px;  
  12. }  

    滑塊中使用了圖片,這樣效果更好點,矩形框的寬度和滑塊圖片設定一致,margin等可以自行繼續微調。下面是關鍵的text地區部分,這裡使用的效果目前僅webkit核心支援,那麼就是說FF暫時不支援該效果。 
Css代碼  
  1. #text{  
  2.     height:50px;  
  3.     width:70%;  
  4.     float:left;  
  5.     padding-top:14px;  
  6.     font-family:"微軟雅黑";  
  7.     font-size:44px;  
  8.     font-weight:100;  
  9.     text-align:center;  
  10.     vertical-align: middle;  
  11.     background: -webkit-gradient(linear,left top,right top,color-stop(0, #4d4d4d),color-stop(0.4, #4d4d4d),color-stop(0.5, white),color-stop(0.6, #4d4d4d),color-stop(1, #4d4d4d));   
  12.     -webkit-background-clip: text;  
  13.     -webkit-text-fill-color: transparent;  
  14.     -webkit-animation: slidetounlock 5s infinite;  
  15.     -webkit-text-size-adjust: none;  
  16. }  

    加上下面的動畫: 
Css代碼  
  1. @-webkit-keyframes slidetounlock {  
  2.     0% {background-position: -200px 0;}  
  3.     100%{background-position: 200px 0;}  
  4. }  

    我們模仿出的最後效果為: 
 
    圖中文字部分動態高亮部門就是其它核心暫時不支援的部分了,這樣我們的效果就完成了,此時都是靜態,什麼操作也做不了,我們使用jqueryUI的draggable來添加動態效果: 
Js代碼  
  1. $(function() {  
  2.     var slideWidth=$("#slide").width();  
  3.     $("#slider").draggable({  
  4.         axis: 'x',  
  5.         containment: 'parent',  
  6.         drag: function(event, ui) {  
  7.             if (ui.position.left > slideWidth*0.7) {  
  8.                 $("#slide").fadeOut();  
  9.                 $("#overlay").fadeOut();  
  10.             } else {  
  11.                 // do nothing  
  12.             }  
  13.         },  
  14.         stop: function(event, ui) {  
  15.             if (ui.position.left < slideWidth*0.7) {  
  16.                 $(this).animate({left: 0});  
  17.             }  
  18.         }  
  19.     });       
  20. });  

    我們動態擷取設定的slide寬度,然後應用draggable方法,設定橫向拖動,並在拖動距離達到矩形長度的70%時,模態層和滑塊消失,還原到頁面中。那麼我們就完成了給頁面添加鎖屏的效果了。 
    最後附上源碼,希望對使用者有用。
  • backend.rar (151.8 KB)

html5/css3怎寫以下這種效果,最好有詳細代碼,給高分

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>淡入陰影製作效果</title><style type="text/css">*{ margin:0px; padding:0;}body{ color:#666; font:16px/1.5 '微軟雅黑',Arial, Helvetica, sans-serif;}img{ border:0 none;}.ullist{ float:left; list-style:none; width:100%;}.ullist li{ background:#eee; float:left; margin:10px; width:228px;}.ullist li a{ border:10px solid #fff; color:#666; display:inline-block; text-decoration:none;}.ullist li a:hover{ box-shadow:0 0 10px #666; transition:all 0.40s ease-in-out;}.fcr{ color:#f00;}</style></head><body><ul class="ullist"> <li><a href="#"><img src="1.jpg" alt="" />詹二鋒-野色風情<br/><span class="fcr">¥40,000</span></a></li> <li><a href="#"><img src="1.jpg" alt="" />詹二鋒-野色風情<br/><span class="fcr">¥40,000</span></a></li></ul></body></html>給你寫了一個例子,運行一下,就可以了。



 
html5/CSS3做一個表格 本人菜鳥初學指導

代碼如下。不支援IE,請用FireFox或者Safair看效果。
這裡主要應用了CSS3的幾個功能圓角邊框“border-radius”,以及偽類別選取器“E:nth-child(n)”。偽類"E:hover"不是CSS3的新功能,它的作用就是當滑鼠移至上方與E元素時樣式發生改變。
親,祝你學有所成喲!

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
.radius {
border-width: 1px;
border-style: solid;
-moz-border-radius: 11px;
-khtml-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
padding:5px;
}
.radius th {background-color:#0000ff;color:#ffffff;}
.radius tr:nth-child(odd) {background-color:#FF0000;}
.radius tr:nth-child(even) {background-color:#00ff00;}
.radius tr:hover{background-color:#FF0;}
</style>
</head>

<body>
<table width="200" class="radius">
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
</tr&......餘下全文>>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.