本篇文章给大家带来的内容是关于css如何实现图像的透明与不透明(完整代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
1.图像透明不透明用到opacity元素,值为0到1,一般用0.4或0.6就够了。
2.ie8以下浏览器写法为:filter:alpha(opacity=40);值为0到100.一般为了兼容同时写两种。
3.用法有两种,第一直接写在图片上增加图片的模糊程度(相当于灰色蒙版);第二把图片写在背景p里,嵌套p写带有颜色的蒙版,里面还可以加文字。具体写法如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> img{ width:400px; height:300px; opacity:0.4; filter:alpha(opacity=40); } img:hover{ opacity:1; filter:alpha(opacity=100);/*ie8以下写法*/ } .background{ background:url('img/t01753ed63dad21cb88.jpg') no-repeat; width:400px; height:300px; } .transparent{ width:400px; height:300px; background-color:#f941f3; opacity:0.4; filter:alpha(opacity=40); } .transparent:hover{ opacity:0; filter:alpha(opacity=0); } p{ font-size:48px; display:block; color:white; text-align:center; line-height:300px; } </style> </head> <body> <img src="img/t010c6ea3d87e5dcc351.jpg"/> <div class="background"> <div class="transparent"> <p>filter:alpha</p> </div> </div> </body> </html>
运行效果:
注意:
1.用伪类:hover可以设置鼠标移动到图片上时的透明度。
2.div写背景图片默认height为0,一定要限定高度才可以显示图片全部尺寸。
相关推荐:
css背景透明文字不透明_html/css_WEB-ITnose
以上是css如何实现图像的透明与不透明(完整代码)的详细内容。更多信息请关注PHP中文网其他相关文章!

是的,youshouldlearnbothflexboxandgrid.1)flexboxisidealforone-demensional,flexiblelayoutslikenavigationmenus.2)gridexcelstcelsintwo-dimensional,confffferDesignssignssuchasmagagazineLayouts.3)blosebothenHancesSunHanceSlineHancesLayOutflexibilitibilitibilitibilitibilityAnderibilitibilityAndresponScormentilial anderingStruction

重构自己的代码看起来是什么样的?约翰·瑞亚(John Rhea)挑选了他写的一个旧的CSS动画,并介绍了优化它的思维过程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingmatematingmultationmatingMultationPropertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用BombingingWithjavofofofofofoffo

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他们可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑战挑战InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)创造性

使用滚动阴影,尤其是对于移动设备,是克里斯以前涵盖的一个微妙的UX。杰夫(Geoff)涵盖了一种使用动画限制属性的新方法。这是另一种方式。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

Dreamweaver Mac版
视觉化网页开发工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

WebStorm Mac版
好用的JavaScript开发工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境