国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
當前位置: 首頁 - 科技 - 知識百科 - 正文

使用css3屬性如何豐富圖片樣式(圓角陰影漸變)_html5教程技巧

來源:懂視網 責編:小采 時間:2020-11-27 15:17:34
文檔

使用css3屬性如何豐富圖片樣式(圓角陰影漸變)_html5教程技巧

使用css3屬性如何豐富圖片樣式(圓角陰影漸變)_html5教程技巧:在css3中,直接在圖片上使用box-shadow 和 border-radius,瀏覽器并不能很好的渲染。但是如果把圖片作為background-image,添加的樣式瀏覽器可以很好的渲染。我將會介紹如何使用box-shadow, border-radius 和 transition創建不同圖片樣
推薦度:
導讀使用css3屬性如何豐富圖片樣式(圓角陰影漸變)_html5教程技巧:在css3中,直接在圖片上使用box-shadow 和 border-radius,瀏覽器并不能很好的渲染。但是如果把圖片作為background-image,添加的樣式瀏覽器可以很好的渲染。我將會介紹如何使用box-shadow, border-radius 和 transition創建不同圖片樣
在css3中,直接在圖片上使用box-shadow 和 border-radius,瀏覽器并不能很好的渲染。但是如果把圖片作為background-image,添加的樣式瀏覽器可以很好的渲染。我將會介紹如何使用box-shadow, border-radius 和 transition創建不同圖片樣式效果。
問題
通過查看demo能注意到,我們為第一行圖片設置了border-radius 和 內嵌box-shadow。firefox渲染了圖片的border-radius,但是沒有渲染內嵌box-shadow。chrome和Safari兩種效果都沒有渲染。

代碼如下:
.normal img {
border: solid 5px #000;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
-webkit-box-shadow: inset 0 1px 5px rgba(0,0,0,.5);
-moz-box-shadow: inset 0 1px 5px rgba(0,0,0,.5);
box-shadow: inset 0 1px 5px rgba(0,0,0,.5);
}

firefox效果:

chrome/safari


變通方案
為了使border-radius 和 內嵌box-shadow能夠正常工作,我們需要把圖片轉換成background-image的方式。

動態方式
為了動態完成這一工作,我們需要借助jquery為每一個圖片添加背景圖片的包裝。下面的js代碼為每一個圖片添加了一個span的包裝,span的背景圖片路徑就是圖片的路徑。
代碼比較簡單,我想就沒有講解的必要了。不清楚了可以直接去查jquery的api。

代碼如下:
輸出如下結果:

代碼如下:


圓形圖片
添加我們使用border-radius來實現圓形圖片的效果,效果如下:

css:

代碼如下:
.circle .image-wrap {
-webkit-border-radius: 50em;
-moz-border-radius: 50em;
border-radius: 50em;
}

卡片風格
下面是卡片風格的圖片,使用了多個內嵌box-shadow。

css:

代碼如下:
.card .image-wrap {
-webkit-box-shadow: inset 0 0 1px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.4);
-moz-box-shadow: inset 0 0 1px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.4);
box-shadow: inset 0 0 1px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.4);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}

浮雕風格
下面是浮雕效果。

css:

代碼如下:
.embossed .image-wrap {
-webkit-box-shadow: inset 0 0 2px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -7px 0 rgba(0,0,0,.6), inset 0 -9px 0 rgba(255,255,255,.3);
-moz-box-shadow: inset 0 0 2px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -7px 0 rgba(0,0,0,.6), inset 0 -9px 0 rgba(255,255,255,.3);
box-shadow: inset 0 0 2px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -7px 0 rgba(0,0,0,.6), inset 0 -9px 0 rgba(255,255,255,.3);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}

柔性浮雕風格
相對于浮雕樣式,新樣式添加了1px blur屬性。

css:

代碼如下:
.soft-embossed .image-wrap {
-webkit-box-shadow: inset 0 0 4px rgba(0,0,0,1), inset 0 2px 1px rgba(255,255,255,.5), inset 0 -9px 2px rgba(0,0,0,.6), inset 0 -12px 2px rgba(255,255,255,.3);
-moz-box-shadow: inset 0 0 4px rgba(0,0,0,1), inset 0 2px 1px rgba(255,255,255,.5), inset 0 -9px 2px rgba(0,0,0,.6), inset 0 -12px 2px rgba(255,255,255,.3);
box-shadow: inset 0 0 4px rgba(0,0,0,1), inset 0 2px 1px rgba(255,255,255,.5), inset 0 -9px 2px rgba(0,0,0,.6), inset 0 -12px 2px rgba(255,255,255,.3);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}

摳圖風格
使用內嵌box-shadow就可以實現摳圖效果。

css:

代碼如下:
.cut-out .image-wrap {
-webkit-box-shadow: 0 1px 0 rgba(255,255,255,.2), inset 0 4px 5px rgba(0,0,0,.6), inset 0 1px 0 rgba(0,0,0,.6);
-moz-box-shadow: 0 1px 0 rgba(255,255,255,.2), inset 0 4px 5px rgba(0,0,0,.6), inset 0 1px 0 rgba(0,0,0,.6);
box-shadow: 0 1px 0 rgba(255,255,255,.2), inset 0 4px 5px rgba(0,0,0,.6), inset 0 1px 0 rgba(0,0,0,.6);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}

變形和發光
在這個例子中我們為圖片包裝添加transition屬性,鼠標滑過的時候,他會從圓角變為圓形。然后我們使用多個box-shadow實現發光效果。

css:

代碼如下:
.morphing-glowing .image-wrap {
-webkit-transition: 1s;
-moz-transition: 1s;
transition: 1s;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
.morphing-glowing .image-wrap:hover {
-webkit-box-shadow: 0 0 20px rgba(255,255,255,.6), inset 0 0 20px rgba(255,255,255,1);
-moz-box-shadow: 0 0 20px rgba(255,255,255,.6), inset 0 0 20px rgba(255,255,255,1);
box-shadow: 0 0 20px rgba(255,255,255,.6), inset 0 0 20px rgba(255,255,255,1);
-webkit-border-radius: 60em;
-moz-border-radius: 60em;
border-radius: 60em;
}

高光效果
高光的效果是通過為元素添加 :after 偽類實現的。

css:

代碼如下:
.glossy .image-wrap {
-webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.5);
-moz-box-shadow: inset 0 -1px 0 rgba(0,0,0,.5);
box-shadow: inset 0 -1px 0 rgba(0,0,0,.5);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
.glossy .image-wrap:after {
position: absolute;
content: ' ';
width: 100%;
height: 50%;
top: 0;
left: 0;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
background: -moz-linear-gradient(top, rgba(255,255,255,0.7) 0%, rgba(255,255,255,.1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.7)), color-stop(100%,rgba(255,255,255,.1)));
background: linear-gradient(top, rgba(255,255,255,0.7) 0%,rgba(255,255,255,.1) 100%);
}

倒影效果
在這個例子中,我們將高光效果移到底部就實現倒影效果。

css:

代碼如下:
.reflection .image-wrap:after {
position: absolute;
content: ' ';
width: 100%;
height: 30px;
bottom: -31px;
left: 0;
-webkit-border-top-left-radius: 20px;
-webkit-border-top-right-radius: 20px;
-moz-border-radius-topleft: 20px;
-moz-border-radius-topright: 20px;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
background: -moz-linear-gradient(top, rgba(0,0,0,.3) 0%, rgba(255,255,255,0) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,.3)), color-stop(100%,rgba(255,255,255,0)));
background: linear-gradient(top, rgba(0,0,0,.3) 0%,rgba(255,255,255,0) 100%);
}
.reflection .image-wrap:hover {
position: relative;
top: -8px;
}

高光和倒影
本例我們使用:before 和 :after 將高光和倒影效果組合起來。

css:

代碼如下:
.glossy-reflection .image-wrap {
-webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.6);
-moz-box-shadow: inset 0 -1px 0 rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.6);
box-shadow: inset 0 -1px 0 rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.6);
-webkit-transition: 1s;
-moz-transition: 1s;
transition: 1s;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
.glossy-reflection .image-wrap:before {
position: absolute;
content: ' ';
width: 100%;
height: 50%;
top: 0;
left: 0;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
background: -moz-linear-gradient(top, rgba(255,255,255,0.7) 0%, rgba(255,255,255,.1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.7)), color-stop(100%,rgba(255,255,255,.1)));
background: linear-gradient(top, rgba(255,255,255,0.7) 0%,rgba(255,255,255,.1) 100%);
}
.glossy-reflection .image-wrap:after {
position: absolute;
content: ' ';
width: 100%;
height: 30px;
bottom: -31px;
left: 0;
-webkit-border-top-left-radius: 20px;
-webkit-border-top-right-radius: 20px;
-moz-border-radius-topleft: 20px;
-moz-border-radius-topright: 20px;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
background: -moz-linear-gradient(top, rgba(230,230,230,.3) 0%, rgba(230,230,230,0) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(230,230,230,.3)), color-stop(100%,rgba(230,230,230,0)));
background: linear-gradient(top, rgba(230,230,230,.3) 0%,rgba(230,230,230,0) 100%);
}

膠帶風格
在這個例子中,我們使用:after來實現膠帶的效果。

css:

代碼如下:
.tape .image-wrap {
-webkit-box-shadow: inset 0 0 2px rgba(0,0,0,.7), inset 0 2px 0 rgba(255,255,255,.3), inset 0 -1px 0 rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
-moz-box-shadow: inset 0 0 2px rgba(0,0,0,.7), inset 0 2px 0 rgba(255,255,255,.3), inset 0 -1px 0 rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
box-shadow: inset 0 0 2px rgba(0,0,0,.7), inset 0 2px 0 rgba(255,255,255,.3), inset 0 -1px 0 rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
}
.tape .image-wrap:after {
position: absolute;
content: ' ';
width: 60px;
height: 25px;
top: -10px;
left: 50%;
margin-left: -30px;
border: solid 1px rgba(137,130,48,.2);
background: -moz-linear-gradient(top, rgba(2,243,127,.6) 0%, rgba(240,224,,.6) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(2,243,127,.6)), color-stop(100%,rgba(240,224,,.6)));
background: linear-gradient(top, rgba(2,243,127,.6) 0%,rgba(240,224,,.6) 100%);
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 1px 0 rgba(0,0,0,.2);
}

變形和著色
在這個例子中,我們在元素上使用:after,當鼠標進過的時候實現徑向漸變的效果。

css:

代碼如下:
.morphing-tinting .image-wrap {
position: relative;
-webkit-transition: 1s;
-moz-transition: 1s;
transition: 1s;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
.morphing-tinting .image-wrap:hover {
-webkit-border-radius: 30em;
-moz-border-radius: 30em;
border-radius: 30em;
}
.morphing-tinting .image-wrap:after {
position: absolute;
content: ' ';
width: 100%;
height: 100%;
top: 0;
left: 0;
-webkit-transition: 1s;
-moz-transition: 1s;
transition: 1s;
-webkit-border-radius: 30em;
-moz-border-radius: 30em;
border-radius: 30em;
}
.morphing-tinting .image-wrap:hover:after {
background: -webkit-gradient(radial, 50% 50%, 40, 50% 50%, 80, from(rgba(0,0,0,0)), to(rgba(0,0,0,1)));
background: -moz-radial-gradient(50% 50%, circle, rgba(0,0,0,0) 40px, rgba(0,0,0,1) 80px);
}

羽化邊緣圓形
我們同樣可以使用徑向漸變產生遮罩,實現羽化的效果。

css:

代碼如下:
.feather .image-wrap {
position: relative;
-webkit-border-radius: 30em;
-moz-border-radius: 30em;
border-radius: 30em;
}
.feather .image-wrap:after {
position: absolute;
content: ' ';
width: 100%;
height: 100%;
top: 0;
left: 0;
background: -webkit-gradient(radial, 50% 50%, 50, 50% 50%, 70, from(rgba(255,255,255,0)), to(rgba(255,255,255,1)));
background: -moz-radial-gradient(50% 50%, circle, rgba(255,255,255,0) 50px, rgba(255,255,255,1) 70px);
}

瀏覽器兼容性
這種實現方式在大多數支持border-radius, box-shadow, :before and :after特性的瀏覽器中(例如Chrome, Firefox 和 Safari),都能很好的工作。在不支持新特性的瀏覽器中,只會顯示原始圖片。
創造你自己的實現
借助:before 和:after偽類能為圖片創造很多種樣式,你可以自己嘗試創建出新的效果。

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

使用css3屬性如何豐富圖片樣式(圓角陰影漸變)_html5教程技巧

使用css3屬性如何豐富圖片樣式(圓角陰影漸變)_html5教程技巧:在css3中,直接在圖片上使用box-shadow 和 border-radius,瀏覽器并不能很好的渲染。但是如果把圖片作為background-image,添加的樣式瀏覽器可以很好的渲染。我將會介紹如何使用box-shadow, border-radius 和 transition創建不同圖片樣
推薦度:
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top 主站蜘蛛池模板: 亚洲一区二区在线 | 大陆日韩欧美 | 免费h视频在线观看 | 欧美日韩国产综合视频在线看 | 国产成人精品第一区二区 | 亚洲精品国产成人99久久 | 久久青青视频 | 欧美一区二区高清 | 亚洲第一页中文字幕 | 欧美精品福利 | 国产一区在线看 | 五十路亲子中出在线观看 | 亚洲97 | 国产不卡一区二区视频免费 | 国产欧美另类久久精品91 | 国产高清在线播放免费观看 | 亚洲首页在线观看 | 欧美日韩亚洲一区二区三区 | 夜精品a一区二区三区 | 综合亚洲一区二区三区 | 国产精品久久久久9999 | 日韩欧美系列 | 久久成人国产精品免费 | 亚洲一区二区精品视频 | 五月天婷婷在线观看 | 欧美亚洲另类综合 | 国外欧美一区另类中文字幕 | 成人区精品一区二区毛片不卡 | 99久久精品国产综合一区 | 亚洲国产精品久久久久 | 国产美女一级毛片 | 日韩在线欧美 | 日韩美一区二区 | 久久伊人一区二区三区四区 | 美女一级毛片 | 国产精品一级片 | 国内精品久久久久激情影院 | 美国美女一级毛片免费全 | 欧美亚洲日本国产 | 欧美亚洲综合另类在线观看 | 大黄毛片 |