How do you get the reblog, like, ect. all in the center of your posts like that? I've been trying to look everywhere for a hint but I don't know where to go, help?
Thanks for your question!
So this is a bit complicated to do, so it’s understandable that you’re having trouble. It took me ages to learn how to do this, and I wish I had had someone to tell me how. But I finally was able to figure it out by pulling information from a variety of sources (and honestly I’m not sure how well I’ll be able to actually explain what everything does, but I’ll do my best!). Also, I’m assuming that, because this is a bit harder to do, you already know basic HTML & CSS (if you don’t, I’d suggest learning how to do simpler things first, and then coming back to this).
By the end of this post, your post information will show up on hover in the center of posts like it does in many of my themes. (See my “New York” theme and my “Clarity” theme for the best examples of this.)
This is going to be a long tutorial with a lot of information, so get ready!
1. If you haven’t already, place a div tag inside the {block:Posts} tags. Feel free to call it whatever you want/feel is the most helpful (the same goes for all of the divs we’ll use in this tutorial). It should look something like this:
2. Next, insert the opening and closing {block:IndexPage} right after the opening “posts” div:
{block:IndexPage}{/block:IndexPage}[Other stuff here]
3. Inside of those tags, enter all of the information you want to show up over your posts (Like, Reblog, Note Count, etc.), and wrap them in a div tag, which will later serve as the “background” of this information. Also, it’s a good idea to wrap each of the pieces of information in their own span tags, so that you can style them later. This part is important; you want to use span tags since I’m assuming that you want the information elements to be side by side, not stacked on top of each other, which is what would happen if you used div tags.
{block:Posts} {block:IndexPage}
{LikeButton color=“grey” size=“14”}{ReblogButton color=“grey” size=“14”}{NoteCount}
{/block:IndexPage}[Other stuff here]
4. Next, you have to add one final div inside of the one that you wrapped the information in. This will serve as the “box” that holds all of the information in the center of the posts:
{block:Posts} {block:IndexPage}
{LikeButton color=“gray” size=“14”}{ReblogButton color=“grey” size=“14”}{NoteCount}
{/block:IndexPage}[Other stuff here]
…And that’s it for the HTML! Now for the CSS, which is where the ~magic~ happens. I’m not going to go into detail about how to style the “posts” tag, because I’m assuming you already know how you want your posts to look, and this tutorial is already über long LOL. So for the sake of this tutorial, let’s just assume that your posts are 250px wide.
5. So the first thing you want to do is to put some space in between the post information, so that it’s not all squished together. For example:
.like { display: inline-block; padding-right: 5px; padding-top: 2px; padding-bottom: 2px; padding-left: 5px;}.rb { display: inline-block; padding-top: 2px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px;}.noteslabel { padding-left: 5px; font-size: 16px; color: #ccc; display: inline-block;}
6. Now it’s time to style the “perm” tag:
.perm { position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; overflow: hidden; background-color: rgba(255, 255, 255, 0.5);}
There are a few things to keep in mind:
The position MUST be absolute, or else it won’t work when you hover over the posts!
The width and height should both be 100%, to match the width and height of your posts.
The “top” and “left” properties should be set to 0.
The opacity MUST be 0; you don’t want the information to show up on top of a post when you’re not hovering over it!
Remember to hide the overflow; this is to prevent anything from spilling over the sides of your posts.
I used the rgba property to make it so that the “background” color is translucent white, but you can change the color and/or opacity if you want to.
7. Style the “box” tag as well:
.box { background-color: #4a404a; text-align: center; position: absolute; width: 100%; top: 50%; transform: translate(0, -50%) padding-top: 2px; padding-bottom: 2px;}
This part is really important, and also the hardest; it is what makes the information horizontally and vertically centered. Here are some pointers:
Setting the “text-align” property to “center” places the information horizontally in the center of the box.
Like the “perm” tag, the “box” tag should be absolutely positioned and should have a width of 100%. (You can also give it a height, but I prefer to just change the padding, which you can play around with.)
The “top” value MUST be set to 50%–this is what aligns the box in the center of the posts!
You also MUST use the “translate” value (which itself has two values–one for the x-axis, and one for the y-axis) of the “transform” attribute to align the “box” element vertically. The x-value is set to 0, so that the “box” element doesn’t go anywhere horizontally, while the y-value is set to 50%, so that it is displayed halfway down the posts’ height.
8. Now for the final step–making the information appear on hover! Simply add “:hover” right after the “posts” tag, and then the “perm” tag after that. This tells Tumblr to show everything contained in the “perm” tag (including the “box” tag, which in turn contains the post information) when you hover over the posts.
#posts:hover .perm { opacity: 1; -moz-transition-duration: 0.8s; -o-transition-duration: 0.8s; -webkit-transition-duration: 0.8s; transition-duration: 0.8s}
In terms of styling, all you really need to do is set the opacity to 1.
However, you can also add in some fancy transition effects if you want (Adjust the values to make the transition happen more quickly or more slowly, and make sure that they’re the same for each browser. I honestly don’t know much about transitions, but you can read more about them here.).
So that’s how I get the post information to be centered and to display on hover. If you made it through all of this, then good job!