Reputation: 94409
Demo: http://jsfiddle.net/DerekL/gNkKx/
I am trying to push up the text in a div
by 50%, and I tried
padding-bottom: 50px; /*div is 100px high*/
But it does not work.
padding-top: -50px;
This does not work too. Any work-around?
Upvotes: 6
Views: 54053
Reputation: 11
A slightly cleaner solution: (building off of Sachleen's)
HTML:
<div class="move-me-up">
<p>Some text</p>
</div>
CSS:
.move-me-up {
position: relative;
top: -50px;
}
This will move the text up 50 pixels on the screen, while only requiring one div!
Upvotes: 1
Reputation: 207
Try raising the text up with inline-block. Use a border to see where you are. By doing this you can see where margin-top can be adjusted up and how large it is.
<div style='display:inline-block;margin-top:-30px; border: 1px solid pink;'>
<font style='color:green;'>today </font>
</div>
Upvotes: -1
Reputation: 31141
line-height:0px;
pushes it up some, but I don't know how much and it's apparently not 50px as you want.
You can wrap the element in another container and position it like so:
HTML
<div class="container">
<div class="block">龍</div>
</div>
CSS (only showing modifications from your style)
.container{
position: relative;
}
.block {
position: absolute;
top: -50px;
}
Upvotes: 11
Reputation: 3603
IF you are trying to center the text within the boxes, try the following:
div.block {
border: 1px solid black;
width: 100px;
height: 100px;
text-align: center;
font-size: 80px;
line-height: 80px;
overflow: hidden;
padding-top: 10px;
}
*{
box-sizing: border-box;
}
Upvotes: 1