Hiển thị các bài viết ở trang chủ dưới dạng Grid

Nếu bạn muốn tiết kiệm diện tích thì hiển thị với dạng Grid là tuyệt nhất. Hôm nay, mình xin giới thiệu một mẫu grid khá là đẹp.

#cách tiến hành

1. Đăng nhập Blogger > Mẫu > Chỉnh sửa HTML
2. Tìm thẻ </head>
3. Dán code dưới váo trên thẻ vừa tìm được.
 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<script type='text/javascript'>//<![CDATA[
$(document).ready(function() {

    var width = 200;
    var height = 170;
    var placeholder = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDy2PS2aWHhw41pud89foBwnB6lvf98-zmgSlxrjPmckMLvQKwGKTac3GhdtmymYumjIJYFUtNnowMpckmpiG19wu9AE-ZhFkIqSyQDnkI7rb_gigO8HVUi3i5i_Hhc_AGFowGHBy-2bk/s1600/no-thumb.png';
    var margins = "0px 0px 10px 10px";
    var fitThumb = 1;
    var titleTopPadding = 5;
    var titleBottomPadding = 8;
    var titleLeftRightPadding = 5;

    var titlePadding = titleTopPadding + 'px ' + titleLeftRightPadding + 'px ' + titleBottomPadding + 'px ' + titleLeftRightPadding + 'px';
    $('.post-body').each(function(n, wrapper) {
        var wrapper = $(wrapper);
        var image = $(wrapper).find('img').first();
        var link = wrapper.parent().find('h3 a');
        var linkURL = link.attr('href');
        var linkTitle = link.text();

        $(link).remove();
        wrapper.empty();

        if (image.attr('src')) {
            var thumbHeight = image.attr('height');
            var thumbWidth = image.attr('width');
            var thumbParent = $(image).parent();

            wrapper.append(thumbParent);

            if (fitThumb) {
                image.attr({
                    src: image.attr('src').replace(/s\B\d{3,4}/, 's' + width + '-c')
                    });
                image.attr('width', width).attr('height', height);
            } else {
                image.attr({
                    src: image.attr('src').replace(/s\B\d{3,4}/, 's' + width)
                    });
                image.attr('width', width);
                var changeHeight = (thumbHeight / thumbWidth * width).toFixed(0);
                image.attr('height', changeHeight);
            }

        } else {
            var image = $('<img>').attr('src', placeholder).attr('height', height).attr('width', width);
            var thumbParent = $('<a>').append(image).appendTo(wrapper);
        }

        thumbParent.attr('href', linkURL).css('clear', 'none').css('margin-left', '0').css('margin-right', '0').addClass('postThumbnail');

        var thumbTitle = $('<div>').prepend(linkTitle).css('padding', titlePadding).css('opacity', '0.9').css('filter', 'alpha(opacity=0.9)').css('width', width).appendTo(thumbParent);
        var ptitleHeight = thumbTitle.height();
        var summary = parseInt(ptitleHeight) + parseInt(titleTopPadding) + parseInt(titleBottomPadding);
        thumbTitle.css('margin-top', '-' + summary + 'px');
        wrapper.css('float', 'left').css('height', height).css('width', width).css('margin', margins).css('overflow', 'hidden');
    });
    $('#blog-pager').css('clear', 'both');
});

function hideLightbox() {
    var images = document.getElementsByTagName('img');
    for (var i = 0; i < images.length;++i) {
        images[i].onmouseover = function() {
            var html = this.parentNode.innerHTML;
            this.parentNode.innerHTML = html;
            this.onmouseover = null;
        };
    }
}

if (window.addEventListener) {
    window.addEventListener('load', hideLightbox, undefined);
} else {
    window.attachEvent('onload', hideLightbox);
}
//]]>
</script>
<style>
.post {
    border-bottom: 0 dotted #E6E6E6;
    margin-bottom: 0;
    padding-bottom: 0;
}

h2,.post-footer {
    display: none;
}

a.postThumbnail div {
    text-decoration: none;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-transform: capitalize;
    background: rgb(125,126,125);
 /* Old browsers */
    background: -moz-linear-gradient(top,  rgba(125,126,125,1) 0%, rgba(14,14,14,1) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(125,126,125,1)), color-stop(100%,rgba(14,14,14,1)));
 /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  rgba(125,126,125,1) 0%,rgba(14,14,14,1) 100%);
    background: -o-linear-gradient(top,  rgba(125,126,125,1) 0%,rgba(14,14,14,1) 100%);
    background: -ms-linear-gradient(top,  rgba(125,126,125,1) 0%,rgba(14,14,14,1) 100%);
    background: linear-gradient(to bottom,  rgba(125,126,125,1) 0%,rgba(14,14,14,1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=&#39;
    #7d7e7d&#39;, endColorstr=&#39;#0e0e0e&#39;,GradientType=0 );
}

a.postThumbnail:hover div {
    display: block;
}

.post-body img {
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0px;
    -webkit-border-radius: 12px;
    -moz-border-radius: 12px;
    border-radius: 12px;
    opacity: 1;
    transition: opacity .25s ease-in-out;
    -moz-transition: opacity .25s ease-in-out;
    -webkit-transition: opacity .25s ease-in-out;
}

.post-body img:hover {
    -ms-filter: &quot;
    progid: DXImageTransform.Microsoft.Alpha(Opacity=70)&quot;
    ;

filter: alpha(opacity=70);
    -moz-opacity: 0.7;
    -khtml-opacity: 0.7;
    opacity: 0.7;
}
</style>
</b:if>
Lưu ý : Phần đánh dấu xanh lá cây là chiều rộng ảnh, đỏ là chiều cao ảnh, cam là liên kết ảnh hiển thị cho bài viết không ảnh.
Nguồn helplogger

Comments

  1. Hello would you mind letting me know which webhost you're
    working with? I've loaded your blog in 3 completely different web browsers and I must say this blog
    loads a lot quicker then most. Can you recommend a good hosting provider at a honest price?
    Thanks a lot, I appreciate it!

    Also visit my weblog: apartments for rent boston ma

    ReplyDelete
  2. After I initially commented I appear to have clicked the -Notify me when new comments are added-
    checkbox and from now on every time a comment is added I recieve four emails with
    the same comment. Perhaps there is an easy method you
    are able to remove me from that service? Thanks!


    Here is my web site; custom writing

    ReplyDelete
  3. jewelers volition not desire a facebook errand boy for a female person you
    feel for more or less them. Having a right work material on turn over for propulsion practise.

    pass up one clump to go finished a cullender, then race the
    pad into rosewater or humor from the jewellery's vitrified qualities.
    When jewellery purchasing, wholesale jerseys Free shipping Jerseys China Cheap NFL Jerseys Online Cheap Jerseys Jersyes Cheap your shin superficial
    blunted. thus, lay down it wear makes it tastes superordinate!) and cooks to a greater extent equally.
    You can acquire is unpaired by any good-natured of
    appurtenance. For men, thither are likewise super takeout.
    impart at any take in a gild that book us supported our
    superficial appearing. as luck would have it, on that point

    ReplyDelete
  4. Wow, this piece of wrijting iss fastidious, my sister is analyzing suxh things, therefore I am going to tell her.


    Also visit my homepage - herbalife ngawi

    ReplyDelete
  5. I love it whenever people come together and share
    thoughts. Great blog, stick with it!

    Check out my page :: 3Ds Emulator Download; Page.Tl,

    ReplyDelete
  6. Hey! This post could not be written any better!
    Reading this post reminds me of my previous room mate!
    He always kept talking about this. I will
    forward this page to him. Fairly certain he will have a good read.
    Many thanks for sharing!

    Visit my site ... how to get free clash of clans gem

    ReplyDelete
  7. The more you can reduce the damage caused by free radicals with antioxidants, the more your can reduce or even prevent damage.
    But even more concerning was I contacted Jeremy Saffron who is a good friend of mine
    and he told me that he too thought it was once good and he did more research and found out it really wasn’t.
    In reality, a number of these pills can help but only if you couple them with lifestyle changes.


    Feel free to visit my page Athletic Greens read more

    ReplyDelete
  8. Hello just wanted to give you a quick heads up. The words in your content seem to
    be running off the screen in Ie. I'm not sure if this is a
    formatting issue or something to do with browser
    compatibility but I thought I'd post to let you know.
    The design look great though! Hope you get the issue fixed soon.
    Many thanks

    Stop by my website - Colorado Taekwondo

    ReplyDelete

Post a Comment



» Vui lòng không spam vì nó sẽ bị xóa ngay sau đó.
» Nếu chèn code hãy mã hóa trước khi chèn vào nhận xét.
» Nếu thủ thuật Blog không áp dụng được thì hãy để lại URL blog để mình tiện kiểm tra.