HTML5/CSS3實現添加鎖屏效果,html5css3實現鎖屏
鎖屏效果,也就是將螢幕置於模態,不允許使用者觸發任何動作,只能解除鎖定後才能繼續使用,jQueryUI的dialog有模態對話方塊,這一點不難做到。那麼,首先需要在頁面中添加一個div層,用於做模態的層:
Html代碼
- <div id="overlay">
其對應的CSS比較簡單,主要設定一下z-index屬性,值設定的很大即可,就能達到覆蓋其餘元素的效果,加上opacity淡化一下背景:
Css代碼
- #overlay{
- height:100%;
- min-width:1280px;
- width:100%;
- position:absolute;
- left:0px;
- top:0px;
-
- opacity:0.7;
- z-index:100;
- }
這樣就有了一個覆蓋頁面之上的層,顯示效果為:
下面是添加解除鎖定的部分,我們模仿iphone解鎖效果,那麼需要添加一下:
Html代碼
- <div id="slide">
- <span id="slider"></span>
- <span id="text">滑動解除鎖定</span>
- </div>
一個圓角矩形框,左側是按鈕圖片,給出一個提示資訊,難度不大:
Css代碼
- #slide{
- position:absolute;
- top:75%;
- width:52%;
- left:24%;
- height:86px;
- border-radius:18px;
- border:1px solid #2F368F;
- border-bottom:1px groovy #2F368F;
- z-index:101;
- background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #2F368F),color-stop(1, #77D1F6));
- opacity:0.9;
- }
這裡設定的z-index要比模態層大,這樣我們才能操控到,沒什麼多說的。
Css代碼
- #slider{
- float:left;
- position:relative;
- cursor:pointer;
- height:44px;
- background: url(../images/arrow.png) no-repeat;
- border-radius:16px;
- margin:-5px;
- text-align:center;
- width: 146px;
- height: 98px;
- }
滑塊中使用了圖片,這樣效果更好點,矩形框的寬度和滑塊圖片設定一致,margin等可以自行繼續微調。下面是關鍵的text地區部分,這裡使用的效果目前僅webkit核心支援,那麼就是說FF暫時不支援該效果。
Css代碼
- #text{
- height:50px;
- width:70%;
- float:left;
- padding-top:14px;
- font-family:"微軟雅黑";
- font-size:44px;
- font-weight:100;
- text-align:center;
- vertical-align: middle;
- 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));
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- -webkit-animation: slidetounlock 5s infinite;
- -webkit-text-size-adjust: none;
- }
加上下面的動畫:
Css代碼
- @-webkit-keyframes slidetounlock {
- 0% {background-position: -200px 0;}
- 100%{background-position: 200px 0;}
- }
我們模仿出的最後效果為:
圖中文字部分動態高亮部門就是其它核心暫時不支援的部分了,這樣我們的效果就完成了,此時都是靜態,什麼操作也做不了,我們使用jqueryUI的draggable來添加動態效果:
Js代碼
- $(function() {
- var slideWidth=$("#slide").width();
- $("#slider").draggable({
- axis: 'x',
- containment: 'parent',
- drag: function(event, ui) {
- if (ui.position.left > slideWidth*0.7) {
- $("#slide").fadeOut();
- $("#overlay").fadeOut();
- } else {
- // do nothing
- }
- },
- stop: function(event, ui) {
- if (ui.position.left < slideWidth*0.7) {
- $(this).animate({left: 0});
- }
- }
- });
- });
我們動態擷取設定的slide寬度,然後應用draggable方法,設定橫向拖動,並在拖動距離達到矩形長度的70%時,模態層和滑塊消失,還原到頁面中。那麼我們就完成了給頁面添加鎖屏的效果了。
最後附上源碼,希望對使用者有用。
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&......餘下全文>>