Southern Listeners

Loading
Thanks to Greenlava for this cool gadget. Get yours here

Monday, November 8, 2010

Blogger Margin Fix

When it comes to tweaking your blog, sometimes you will find some of your page elements being shifted away from its original desired position. And most of the times you wouldn't find an easy fix for this. This tends to happen when you are hiding an element from your page. As a result, some gap is resulted at the place where the element was supposed to be, causing a distorted look.


In this tutorial, you will learn a simple trick on how to 'pull' a page element towards a certain direction using CSS code. I wanted to include this tweak in my previous tutorial, when I was writing on how to hide an annoying tag that would appear in label pages. Then again, I thought it'd be better if this tweak has it's own page as well. So here it is.


Step 1:

First we'd have to identify the Class or ID of the element that we are going to fix. In the example from my previous tutorial, this is what FireBug's inspection yielded:


So I will be pulling this element upward by addressing it's class, which is column-center-inner.

Step 2:

To fix the margin, I will be using the followinc CSS code:
.column-center-inner{
margin-top: -30px; 
}
The value 30 is arbitrary. You gotta adjust this value by trial and error. But if you're gonna do this often, I suggest you get yourselves useful add-ons, like MeasureIt.

Step 3:

Even though the CSS code above will do the job, applying it to your whole template will not be a good idea because it will shift your posts up in all the pages in your blog. It is okay if you're having the margin problem in all of your pages. In that case, you can apply the code in Step 2 to all of your pages by going to Template Designer - Advanced - Add CSS - Paste the code - Apply to blog.

But if you were following my previous tutorial, you will be having problems in selected pages only. So you should not apply the fix to all of your pages. What we're gonna do now here is apply our fix to one selected page alone. From your template's Edit HTML - Find for </b:skin> - Paste the following code directly below </b:skin> :
<b:if cond='data:blog.url == "http://southernspeakersv2.blogspot.com/search/label/Tutorial"'>
<style>
.column-center-inner{
margin-top: -30px; 
}
</style>
</b:if>
Of course, don't forget to change the URL above to the URL of the page you want the fix to apply. My inserted code looks like this in Edit HTML:


That's about it! See the final result below:


43 comments:

  1. Hey, I tried this, and it worked! Haha.

    However, when I check out the previous entries of my blog, the margin's wonky again. My pages are all fixed, but.. the previous entries. D:

    Dyou have any suggestions or tips on how to fix this?

    ReplyDelete
  2. @The Raspberry Scribbler: Have you removed the code from your blog already? Because I can't seem to find the code in place in any one of your blogs. If the problem is still there, place the code in your blog and get back to me.

    Cheers and God bless.

    ReplyDelete
  3. How can i do it for mulitple pages, for example for 6 diferent labels?

    ReplyDelete
  4. @yourminigames.com: Im afraid you'd have to replicate the same code 6 times. Cheers.

    ReplyDelete
  5. Hi. I'm trying to reduce the margin on my left-hand sidebar, however nothing's working. If you look at the page as a whole, it looks as if the whole section underneath the header is shifted to the right. Thanks so much for your help!

    http://enjoyerofgrace.blogspot.com/

    ReplyDelete
    Replies
    1. Hi weiya,

      If I get you right, this is what you're looking for. Go to Template Designer - Advanced - Add CSS - paste the following code - Press enter after the last character of the last line } - Apply to Blog:

      .main-inner{
      left: -20px !important;
      }

      Adjust the value 20 accordingly.. Cheers :)

      Delete
  6. I have problem in margins in my blog can you help me it is a small problem and it can be solved very fast if you helped me.

    ReplyDelete
    Replies
    1. Hi Shady,

      Sorry for the late reply. Sure thing. What's the problem?

      Cheers :)

      Delete
    2. after i have entered my problem here in this comment it says Your HTML cannot be accepted: Tag is not allowed: DIV
      as i have entered HTML codes to explain my problem so if you can chat with me at Facebook to solve my problem it will be better and faster so this is my profile send me friend request.
      http://www.facebook.com/shady.moustafa.193

      Delete
    3. Hi Shady,

      I do not have a Facebook account (not a fan of the whole social networking stuffs). Please encode your HTML before pasting into Blogger's comment system, or, you could start a question thread here and get back to me with its link.

      Cheers..

      Delete
    4. Thanks
      i have added my problem
      https://productforums.google.com/forum/#!category-topic/blogger/how-do-i/Vgm7GqXGV7g

      Delete
  7. Hi Yoga,
    Do you know how can i remove reply button from blogger comments ? without removing threaded comment ?

    ReplyDelete
    Replies
    1. Hi Shady,

      Use this:

      .comment-actions.secondary-text{
      display: none !important;
      }

      Cheers..

      Delete
    2. Thanks Yoga,
      Another question please you know that when i press reply to a comment the comment box with the smiles box picture jump down to the comment that i press reply to it and the vertical and horizontal position changes to be under the comment but i do not want the horizontal position be changed as when i press reply i see the comment box with its background with the smiles box picture both comes out of the post layout to reach the left side bar widgets can i prevent that from happening and only the vertical position changes not the horizontal ?

      Delete
    3. Hi Shady,

      I'm not quite following. Could you make your question a bit concise? Also, an annotated screenshot could help to explain your issue better.

      Delete
  8. another question

    i have added line at the end of every post by and i have customized it by css code it appears perfect in google chrome but in firefox it appears that there are big space under it but how can i make it appears perfect in all browsers is there are a css code that by it i can force something to be margined only in firefox not in chrome ?

    ReplyDelete
    Replies
    1. Unfortunately, there isn't a way to apply browser-specific CSS code. BTW, I've seen your blog in Firefox, and there doesn't seem to be any gap at all. What am I missing? Could you send me a screenshot of what you're seeing?

      Delete
  9. Thanks for your efforts yoga i have solved these problems but the are two problems that still there and i can not solve them
    the first
    in my blog there are in the bottom right scroll to up button which i add to it hover rotation effect by this codes

    #topcontrol img:hover {
    transform:rotate(360deg);
    -ms-transform:rotate(360deg); /* IE 9 */
    -moz-transform:rotate(360deg); /* Firefox */
    -webkit-transform:rotate(360deg); /* Safari and Chrome */
    -o-transform:rotate(360deg); /* Opera */
    transition: all 1s;
    }

    and it rotates fine in firefox but not rotate in chrome and i do not know what is the problem
    i have tried to make the code like this

    #topcontrol :hover {
    transform:rotate(360deg);
    -ms-transform:rotate(360deg); /* IE 9 */
    -moz-transform:rotate(360deg); /* Firefox */
    -webkit-transform:rotate(360deg); /* Safari and Chrome */
    -o-transform:rotate(360deg); /* Opera */
    transition: all 1s;
    }

    all of them not roate in chrome but rotates perfect in firefox

    and when i make it like this with the id of the widget

    .HTML4 img:hover {
    transform:rotate(360deg);
    -ms-transform:rotate(360deg); /* IE 9 */
    -moz-transform:rotate(360deg); /* Firefox */
    -webkit-transform:rotate(360deg); /* Safari and Chrome */
    -o-transform:rotate(360deg); /* Opera */
    transition: all 1s;
    }

    it is not working in both browsers firefox and chrome what can i do ?

    the second problem.. i will tel you about it in the second reply.
    Thanks.

    ReplyDelete
    Replies
    1. Try this one instead:

      #topcontrol img:hover{
      transform:rotate(360deg) !important;
      transition-duration: 1s !important;
      -ms-transform:rotate(360deg) !important;
      -ms-transition-duration: 1s !important;
      -moz-transform:rotate(360deg) !important;
      -moz-transition-duration: 1s !important;
      -webkit-transform:rotate(360deg) !important;
      -webkit-transition-duration: 1s !important;
      -o-transform:rotate(360deg) !important;
      -o-transition-duration: 1s !important;
      }

      Cheers.

      Delete
    2. woow thank you very much Yoga it rotates now with chrome

      the second problem is that my blog description is not showing in google i do not know why
      description of posts is perfect in google search but description of my blog is wrong it shows some parts of posts title and content but i want the description that i have entered it in setting > basic > description and setting > search preferences > Description why description of my blog that i entered it in this places not showing in Google ??
      Thanks

      Delete
    3. Try adding description meta data to your template's HTML. Google search 'Blogger Meta Description' or something to that effect and look up for tutorials. You'll stumble upon hundreds of methods on various SEO websites.

      Also, the changes will not be immediately visible. You need to wait for Google to re-index your blog to see if the description has worked.

      Cheers..

      Delete
  10. Thanks you
    my blog looks good in all resolutions except 1024 * 768 and down it looks not good so is are any code to make check of the resolution of the visitor if it is 1024 * 768 then make zoom out automatic ?

    ReplyDelete
    Replies
    1. I'm afraid I'm not aware of such code. Do poke around Google though, you might find something useful.

      Delete
    2. Thanks but as you can see my avatar in comments is not showing now so how can i re upload my avatar ? i think i have deleted it from google picasa by mistake also my blogger avatar is still there but in comments as you can see not showing so what can i do ?

      Delete
    3. If you have Google+ upload your picture there. Otherwise go to your Dashboard and look for your Profile page.

      Delete
    4. I have re uploaded it from blogger and it is now appears in comments

      the problem of description is that i know that are many ways in internet but i am afraid to do one way and it will be wrong specially that i will not get the results fast as changes of that things needs time

      so this code is good if i put it bellow head does it will solve my problem with description

      http://img834.imageshack.us/img834/3505/07022013101707.jpg

      but does that code will appear only when i search Google for my blog home page ? or it will be the defult description for all topics in my blog as i do not want that ?

      Delete
    5. This is all SEO related, and I'm not well-versed in it. You can't hit the target, if you don't give it shot. So give it a try, and see if it works. You can use a test blog if you're afraid of messing up your template. But do note that these things take time to appear in search result, as some times, it'll take up to a month (or maybe even longer) for a blog to get re-indexed.

      Delete
  11. the problem of avtar solved
    and i have connected my google plus with blogger but i have problem see this picture to know it

    http://img812.imageshack.us/img812/8516/08022013011453.jpg

    the number 1 comment was published when i was in blogger account
    the number 2 comment was published after i connected google plus with blogger

    but you will notice that avatar in first comment is clear but the comment that published after i conceted my g+ with blogger seems not clear as my avtar in google plus is bigger than my avtar in blogger so when they both resised to 45px * 45px the avtar which is 250px 250px of google pllus stretched to 45px * 45px so it looks strange. but how can i fix this ? also i have not see that thing in bloggers of people that linked it with google plus.

    ReplyDelete
    Replies
    1. Can we take this to the forum? Post it in the forum (I've given you the link before) and get back to me with its link.

      Delete
    2. ok i have post it here
      https://productforums.google.com/forum/#!category-topic/blogger/how-do-i/-Qoi0hZIZmk

      Delete
  12. thanks Yogo but there are another problem that appeared i have put it here
    https://productforums.google.com/forum/#!category-topic/webmasters/crawling-indexing--ranking/xPzwIZtbs80
    help me please.

    ReplyDelete
    Replies
    1. Hi Shady,

      I'm an official TC in Blogger help forum. Webmaster is a whole another Google product that I am not familiar with. Unfortunately, my expertise is limited within the boundary of Blogger..

      Delete
  13. Great bro..
    I have solved my problem.
    Thank you very much!!!

    ReplyDelete
  14. thanks brooo.. its very helpful..!

    ReplyDelete
  15. Hi, I hope you can help me eliminate or minimize the left margin indents on my blog's dynamic view pop-up posts. It's such a waste of space. http://diamondbums.blogspot.com/
    Thanks!

    ReplyDelete
    Replies
    1. See if this helps:

      http://www.southernspeakers.net/2012/02/maximize-post-width-in-blogger-dynamic.html

      Delete
  16. Hi.

    First of all, great blog. For novices like me, your blog is priceless. I've used a few of your tweaks and they've all worked like a treat.

    This one's giving me some trouble, though. If I use the CSS code in the Template Designer, it works. But the HTML one is not working. This is the offending page.

    http://www.as-riddikulus.blogspot.in/search/label/Football

    Can't figure out what I'm doing wrong.

    ReplyDelete
    Replies
    1. Sorry for the late reply. I bet the conditional codes (like the one in Step 3) isn't working. Instead of using http://www.as-riddikulus.blogspot.in/search/label/Football, try http://www.as-riddikulus.blogspot.com/search/label/Football (use .com instead of ccTLD)

      Delete
    2. Hi Yoga, that last suggestion worked for me - my page addresses included .co.uk, which I changed to .com and now they are all aligning perfectly.

      Thanks so much for spending the time to share your knowledge - your tutorials have helped me so much with my Blog this week - Cheers!

      PS: sorry Ashish if your pages are still not working.

      Delete
  17. Can you share the code you're using?

    ReplyDelete
  18. saya kesulitan untuk mengubah margin pada blog saya?

    bisakah bantu saya untuk mengubah ukuran pada margin, karena saya ingin menambahkan sidebar pada sisi kanan saya, mohon bantuannya di sini http://belajar-template-sendiri.blogspot.com/

    terima kasih.

    ReplyDelete
    Replies
    1. Hello there,

      I can not view your blog anymore. Have you changed the URL? Link nya tidak bisa dibuka.

      Delete

Please use the 'Ask a Question' page to shoot questions that are not related to the tutorial in the post above.