HTML / CSS - 在图像上创建alpha蒙版 [英] HTML/CSS - create alpha mask over image

查看:215
本文介绍了HTML / CSS - 在图像上创建alpha蒙版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我正在构建的网站中创建一个效果,其中图像被叠加层遮住。叠加层应该创建一个淡出效果 - 我实际上不想要任何动画,但叠加应该使图像看起来好像在边缘渐变为背景颜色。



如下所示: http://imgur.com/fqtc9.png p>

我喜欢使用CSS / HTML / JS - 而不是图片。任何想法从哪里开始?感谢。

解决方案

您可以这样做,例如:示例



html

 < div class =photo_container> 
< div class =photo>
< img src =/ lakenwoods / images / mockup-photo.pngwidth =540height =463/>< / div>
< div class =overlay>
< div class =content>
< h1>欢迎来到Lake-N-Woods Realty< / h1>
< p>
我们是一家多元化和高效的房地产公司,致力于满足我们所有的客户需求。我们专注于娱乐,农村和投资房地产Bemidji和明尼苏达州中北部。
< / p>
< / div>
< / div>
< div class =clear>
< / div>
< / div>

CSS

  @charsetutf-8; 
/ * CSS文档* /

.clear {
clear:both;
}

.photo_container {
position:relative;
width:540px;
height:463px;
overflow:hidden;
margin:0; padding:0;
}

.photo_container .photo {
z-index:1;

}


.photo_container .overlay {
width:540px;
height:463px;
background:url(/lakenwoods/images/mockup-overlay.png)no-repeat top center;
position:absolute;
bottom:0;
left:0;
z-index:10;

}

.photo_container .overlay .content h1 {

position:absolute;
top:310px;
left:34px;
font-family:Helvetica,Helvetica Neue,Arial,sans-serif;
font-size:18px;
color:#fff;
font-weight:700;
width:315px;

}


.photo_container .overlay .content p {


position:absolute;
top:335px;
left:34px;
font-family:Helvetica,Helvetica Neue,Arial,sans-serif;
font-size:12px;
color:#fff;
width:315px;
line-height:1.4em;

}


I'd like to create an effect in a site I’m building where an image is masked by an overlay. The overlay should create a "fade out" effect — I don’t actually want anything animated, but the overlay should make the image look as if it’s fading to the background colour at the edges.

Something like this: http://imgur.com/fqtc9.png

I prefer to do this with CSS/HTML/JS - not images. Any thoughts on where to start? Thanks.

解决方案

you could do something like this for example : Example

html

<div class="photo_container">
        <div class="photo">
<img src="/lakenwoods/images/mockup-photo.png" width="540" height="463" /></div>
        <div class="overlay">
            <div class="content">
                <h1>Welcome to Lake-N-Woods Realty</h1>
                <p>
                We are a Diverse and Highly Effective Real Estate Company, Dedicated to Satisfying all of our Clients Needs. We Specialize in Recreational, Rural and Investment Property throughout Bemidji and North Central Minnesota.
                </p>
                </div>
        </div>
        <div class="clear">
       </div>
   </div>

CSS

@charset "utf-8";
/* CSS Document */

.clear {
    clear:both;     
}

.photo_container {
    position: relative;
    width: 540px;
    height: 463px;
    overflow:hidden;
    margin: 0; padding:0;
}

.photo_container .photo {
    z-index:1;

}


.photo_container .overlay {
    width: 540px;
    height: 463px;
    background: url(/lakenwoods/images/mockup-overlay.png) no-repeat top center;
    position:absolute;
    bottom: 0;
    left: 0;
    z-index:10;

}

.photo_container .overlay .content h1 {

    position:absolute;
    top: 310px;
    left: 34px;
    font-family: Helvetica, Helvetica Neue, Arial, sans-serif;
    font-size:18px;
    color: #fff;
    font-weight: 700;
    width: 315px;

}


.photo_container .overlay .content p {


    position:absolute;
    top: 335px;
    left: 34px;
    font-family: Helvetica, Helvetica Neue, Arial, sans-serif;
    font-size:12px;
    color: #fff;
    width: 315px;
    line-height: 1.4em; 

}

这篇关于HTML / CSS - 在图像上创建alpha蒙版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆