图片阴影效果实现

图片或边框的阴影效果在web app中经常会意见,以下是归纳的几种简单的实现方法

实现一:

<style type="text/css">
<!--
/* easy drop shadow
================================== */
.img-wrapper {
  background: url(images/shadow.gif) no-repeat bottom right;
  float:left;
  line-height:0;

}
 
.img-wrapper img {
  background:#fff;
  padding:4px;
  border:1px solid #a9a9a9;
  position:relative;
  left:-5px;
  top:-5px;
}
-->
</style>

<div class="img-wrapper">
    <img src="images/dunstan.jpg" width="300" height="300" alt="Dunstan Orchard" />
</div>

 实现二:

<style type="text/css">
<!--

/* easy drop shadow
================================== */

.img-wrapper {
  background: url(images/shadow.gif) no-repeat bottom right;
  clear: right;
  float: left;
  position: relative;
  margin: 10px 0 0 10px;
}
 
.img-wrapper img {
  /*background-color: #fff;
  border: 1px solid #a9a9a9;
  padding: 4px;*/
  display: block;
  margin: -5px 5px 5px -5px;
  position: relative;
}
-->
</style>
<div class="img-wrapper">
     <img src="images/dunstan.jpg" width="300" height="300" alt="Dunstan Orchard" />
</div>

 实现三:

<style type="text/css">
<!--

/* easy drop shadow */

.img-wrapper {
  background: url(images/shadow.gif) no-repeat right bottom;
  float: left;
	/*margin: 10px 0 0 10px;*/
}

.img-wrapper div {
  background: url(images/mask.png) no-repeat left top !important;
  background: url(images/mask.gif) no-repeat left top;
  padding: 0 5px 5px 0;
	float: left; /* :KLUDGE: Fixes bug in IE/Mac */
}
 
.img-wrapper img {
  background-color: #fff;
  border: 1px solid #a9a9a9;
	padding: 4px;
}
-->
</style>
<div class="img-wrapper">
  <div>
    <img src="images/dunstan.jpg" width="300" height="300" alt="Dunstan Orchard" />
  </div>
</div>

 实现四:

<style type="text/css">
<!--

/* easy drop shadow
================================== */

.img-wrapper {
 background:url(images/shadow.gif) no-repeat right bottom;
 float: left;
}

.img-outer {
  background:url(images/bottom-left2.gif) no-repeat left bottom;
  float: left; /* :KLUDGE: Fixes problem in IE5.2/Mac */
}

.img-inner {
  background:url(images/top-right2.gif) no-repeat top right;
  padding: 0 5px 5px 0;
  float: left; /* :KLUDGE: Fixes problem in IE5.2/Mac */
}

.img-wrapper img {
  background-color: #fff;
  border: 1px solid #a9a9a9;
  padding: 4px;
  display: block;
}

-->
</style>

<div class="img-wrapper">
   <div class="img-outer">
      <div class="img-inner">
        <img src="images/dunstan.jpg" width="300" height="300" alt="Dunstan Orchard" />
      </div>
    </div>
</div>
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Mapbox GL JS的符号层(symbol layer)中为图片增加阴影和立体效果,可以使用符号层的`paint`属性来定义阴影和立体效果。下面是一个示例,演示如何为符号层的图片添加阴影和立体效果: ```javascript map.on('load', function() { map.addLayer({ id: 'symbols', type: 'symbol', source: { type: 'geojson', data: { type: 'FeatureCollection', features: [ { type: 'Feature', geometry: { type: 'Point', coordinates: [longitude, latitude] // 设置坐标 }, properties: { icon: 'your-icon-url', // 设置图片的URL size: 1 // 设置图片的大小 } }, // 其他要素... ] } }, layout: { 'icon-image': ['get', 'icon'], 'icon-size': ['get', 'size'] }, paint: { 'icon-opacity': 0.8, // 设置图片的透明度 'icon-translate': [0, 2], // 设置图片的垂直偏移,用于创建立体效果 'icon-translate-anchor': 'map', // 设置垂直偏移的锚点为地图 'icon-shadow-color': '#000000', // 设置阴影颜色 'icon-shadow-opacity': 0.5, // 设置阴影透明度 'icon-shadow-blur': 5 // 设置阴影模糊程度 } }); }); ``` 在上述示例中,我们通过设置符号层的`paint`属性来为图片添加阴影和立体效果。具体来说,我们使用`icon-opacity`属性设置图片的透明度,使用`icon-translate`属性设置图片的垂直偏移,用于创建立体效果。我们还使用`icon-translate-anchor`属性将垂直偏移的锚点设置为地图。此外,我们使用`icon-shadow-color`属性设置阴影的颜色,使用`icon-shadow-opacity`属性设置阴影的透明度,使用`icon-shadow-blur`属性设置阴影的模糊程度。 您可以根据需要调整阴影和立体效果的属性值,以实现不同的效果。请确保将`your-icon-url`替换为您自己的图标URL,并根据需要设置其他符号图层的属性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值