user-pic

图片阴影相框css的制作

Vote 0 Votes

如果没有进行CSS设置,MT默认模版的图片显示比较单一。你可以进行简单的设置,就可以让图片呈现图片阴影相框。如下图:

pic_css.png


1、在css中添加,具体的边框大小、颜色请自己根据模版调整
/* 图片阴影相框*/

.img-bg {
background-image: url(http://bblog.biz/images/shadow.gif);
background-repeat: no-repeat;
background-position: right bottom;
margin: 4px;
padding: 0px;
position: relative;
}
.img-bg img {
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
margin: -5px 5px 5px -5px;
padding: 4px;
position: relative;
}
/* 图片居左文字围绕 */
.img_L {
float: left;
margin: 6px 10px 5px 0px;
border: none;
}
/* 图片居右文字围绕*/
.img_R {
float: right;
margin: 6px 0px 5px 10px;
border: none;
}

然后进入 lib/MT/app/CMS.pm


将lib/MT/app/CMS.pm中的

if ($thumb) {

return <<HTML;
<a href="$url"><img alt="$fname" src="$thumb" width="$thumb_width" height="$thumb_height" border="0" /></a>
HTML
} else {
return <<HTML;
<img alt="$fname" src="$url" width="$width" height="$height" border="0" />
HTML
}


修改为
if ($thumb) {

return <<HTML;
<div class="img-bg img_L" style="width: $width px;"><a href="$url"><img alt="$fname" src="$thumb" width="$thumb_width" height="$thumb_height" border="0" /></a></div>
HTML
} else {
return <<HTML;
<div class="img-bg img_L" style="width: $width px;"><img alt="$fname" src="$url" class="img_L" width="$width" height="$height" border="0" /></div>
HTML
}


以后上传文件的时候就会自动生成如下代码:
<div class="img-bg: img_L" style="width: 200px;"><img alt="pic_css.png" src="http://bblog.biz/upload/images/pic_css.png" width="200" height="200" /></div>

你需要将其中的 style="width: **px; 加上10px 这样显示效果会更好。如果不能修改CMS你可以自己上传图片后添加<div class="img-bg img_L" style="width: **px;"></div>
注意在设置CMS的时候 $width px;之间有空格(如果不加空格会导致CMS无法识别),当然发文的时候最好把这个空格去掉,否则对显示有所影响。

ps:因为我的模版使用了<?xml version="1.0" encoding="utf-8"?> 所以padding 在IE下无法显示,以至于该相框在本站的显示并不是最好的效果。

Add a Reply

Forum Groups

Blogcs 基于MT平台的BSP

MovableType 中文化

1 0

Last Topic: Movable Type 中文化 - 平生一笑 by bb on 2008年10月11日

1 0

Last Topic: Zhu8's Weblog:猪八的网:浮生志 by Zhu8 on 2008年10月16日

MovableType 问题咨询

Be the first to post a topic in this forum

MovableType 使用

16 11

Last Topic: Image::Magick 模块的安装 by bb on 2008年11月 9日

30 35

Last Topic: MT-Twitter:将MT文章同步到Twitter by bb on 2008年3月 9日

22 1

Last Topic: 修改MT的作者归档路径 by bb on 2008年10月25日

MovableType 模板

Be the first to post a topic in this forum

22 17

Last Topic: MovableType评论格式化 replies-to-replies by bb on 2008年10月15日

MovableType 延伸

14 17

Last Topic: 从Wordpress转移到Movabletype by bb on 2007年5月12日

2 2

Last Topic: 最新版MovableType 4.22 已经发布 by bb on 2008年11月19日