From 8f1bc2c8cec3922cde0daa3a5dd2c698199bac60 Mon Sep 17 00:00:00 2001 From: Roc Date: Thu, 17 Sep 2015 15:14:07 +0800 Subject: [PATCH] Add title to article and fancybox title;custum css on title --- source/css/_custom/custom.styl | 32 +++++++++++++++++++++++++++++++- source/js/fancy-box.js | 10 +++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/source/css/_custom/custom.styl b/source/css/_custom/custom.styl index 1ff59cca2..306cda27d 100644 --- a/source/css/_custom/custom.styl +++ b/source/css/_custom/custom.styl @@ -1 +1,31 @@ -// Custom styles. \ No newline at end of file +// Custom styles. + +.post-body p img { + margin: 0 auto; + cursor: pointer; + cursor: zoom-out; + cursor: -webkit-zoom-in; + display: block!important; +} + +.post-body p .pic-title { + margin: 0 auto; + text-align: center; +} + +.post-body p .pic-title span { + min-width: 20%; + min-height: 22px; + display: inline-block; + padding: 10px; + margin: 0 auto; + border-bottom: 1px solid #d9d9d9; + font-size: 18px; + color: #999999; + font-style: italic; + line-height: 1.7; +} + +.posts-expand .post-body .fancybox img { + margin: 0 auto; +} \ No newline at end of file diff --git a/source/js/fancy-box.js b/source/js/fancy-box.js index 0cdded8d5..3a6511f9f 100644 --- a/source/js/fancy-box.js +++ b/source/js/fancy-box.js @@ -1,4 +1,5 @@ $(document).ready(function() { + $('.content img').each(function () { var $image = $(this); var $imageWrapLink = $image.parent('a'); @@ -7,9 +8,10 @@ $(document).ready(function() { $imageWrapLink = $image.wrap('').parent('a'); } $imageWrapLink.addClass('fancybox'); - if(this.title){ - $imageWrapLink.attr("title",this.title); //make sure img title tag will show correctly in fancybox - } + if ($image.attr("alt")) { + $imageWrapLink.append('
' + $image.attr("alt") + '
'); + $imageWrapLink.attr("title",$image.attr("alt")); //make sure img title tag will show correctly in fancybox + }; }); }); $('.fancybox').fancybox({ @@ -19,3 +21,5 @@ $('.fancybox').fancybox({ } } }); + +