align text-line to bottom - css

CSS aligns the text in the middle of the line, but I'd like to have the text aligned to the bottom of the line. Best explained with a picture:
Like it should be:
https://lh5.googleusercontent.com/-L1TBqTxEVHI/UDPVEOnFY7I/AAAAAAAAAH4/GHZHt776wmg/s145/CD-Manual_Stand_Mai_2011_Verlinkungen.pdf%2520%2528Seite%2520135%2520von%2520248%2529.jpg
Like it is:
https://lh6.googleusercontent.com/-0SiQqqkHD9k/UDPVNvTA2NI/AAAAAAAAAIA/2VudybQxnDE/s45/CSSEdit.jpg
Vertical-align doesn't work, it does only work for nested elements and not the entire text. Where's the trick? :)
Here is the code: jsfiddle.net/vmadd

Try line-height: 100%
that should fix you problem.

I don't actually see what you are after. There is no such thing as a baseline alignment or something in standard css (to my knowledge). I don't realy see what that would change in the layout eather.
As for the footer, if you just want some more space between the line and the text, there are plenty af ways to achieve this. Something like this:
div.layoutGridBottom p {
padding-top: 10mm;
}
Should do the trick. Or even better, declare a special class for things you want to have some top padding, and apply it to the elements you want. As said, there are dozens of ways to achieve this (line-height, margin-top, insert blank div, make the line have padding bottom, ...) If you wrote that css yourself, I'm surprised this causes you problems...

Related

Is there a way to avoid widows when placing an image at the end of a paragraph?

I have a site where the client wants to be able to put a stylized graphic at the end of some link text. Conceptually, it'd be like this:
This is My Fancy Title<img src="fancypic.png"/>
Except at some widths, word-wrapping causes the image to wrap as a widow on it's own line.
I've tried quite a few different approaches to this, including the widows CSS property, but nothing seems to work 100%.
Any suggestions?
You can use white-space: nowrap.
That will cause the text and image to not wrap to the next line.
Add a span and put one or 2 words and the image in it, make it inline-block
span {
display: inline-block;
}
This is My Fancy <span>Title<img src="fancypic.png"/></span>

Positioning Facebook like buttons alongside images

http://jsfiddle.net/ADLrh/
Hopefully you can see what I'm after. The three 'fillers' on the top row have sunk, upsetting the pyramid-like formation. Any idea what's causing this?
EDIT: I should also add that the method I go for needs to be flexible because potentially any filler could be a like button and the actual pyramid is quite a lot bigger.
Indeed, like Guy suggested, you're going to want to use the float property rather than display: inline-block, because inline-block is pretty finicky for vertical alignment when using different types of elements next to each other, with whitespace between them.
However, to keep the "pyramid" form, you'll want to wrap the buttons in another div that IS set to display: inline-block, to allow the whole row to center in the current parent div.
Like in this example: http://jsfiddle.net/syd8L/
Remove the white spaces between the HTML elements. This is not however the case where you should use display: inline-block;. Analyze this example. You could use float instead, then you wouldn't need to worry about whitespaces between HTML elements.
Easiest way would be to add some relative positioning to the buttons on the first row, like this:
http://jsfiddle.net/ADLrh/1/
Where you have display: inline-block, you should also add vertical-align: top.
See: http://jsfiddle.net/thirtydot/ADLrh/2/

CSS second-line indent not working

Page in question: http://www.rjlacount.com/public/lander/
I'm probably just doing something stupid, but I'm trying to indent the second line of wrapping text inside the form (with "Your account: test#test.com" at the top) and I can't seem to get anything to work.
I would think the solution is:
form span {padding-left:1.5em;text-indent:-1.5em;}
but this only seems to indent the first line of each section.
Another look at this would be much appreciated, thanks!
If the element is inline it will indent the first line, otherwise if it's a block element it will indent the rest of the lines, which is just like Briguy37 said, since that's the difference between DIV and SPAN.
I just wanted to clear out that it's not a "problem with span".
For some reason, this works with a DIV, but not with a SPAN. Not really sure why, but here's a fiddle with the same CSS for both.
spans are handled as inline elements.
Considering them as actual characters helps to conceptualize the changes. A space after a span is retained because it's like a space between characters. You adjust height by line-height rather than simply height. etc etc
Usually if this is causing a problem you can just use a div and set display:inline-block; if you need horizontal alignment.

How can I wrap a floated span underneath another floated span, within a floated span [diagram included]?

I have a newsfeed/chat box. Each entry contains two spans: #user and #message. I would like #user to float left, and #message to float left upon it. If #message causes the row to exceed the container width, #message should wrap below #user, as shown in the diagram below.
By default #message jumps completely beneath #user if it does not fit on the same row.
I have tried whitespace:nowrap on each element but that doesn't seem to do the trick either.
Help?
Maybe I'm missing something, but if both elements are display:inline this should solve the problem of #message going completely beneath #user. No need to float anything.
Demo (not much to see): http://jsfiddle.net/YK3R9/
Feel free to use semantic markup instead of spans and divs, I just used them for the demo.
If you need the border on message to display the way it is in your drawing, just say so. I wasn't sure if it was a visual aid or the way you actually want it rendered. Simply adding the border to the element looks a bit weird when the message spans multiple lines, so we might need a helper span.
EDIT: Saw your note that borders don't matter.
Moral of the story: No need for float here.

How to make a button stretch across the width of a column

I'm trying to make a button span the width of a column.
e.g. here: http://davidnhutch.com. Notice how the light grey buttons are only as large as the text they contain? I'd like each button to span the width of that column, but can't for the life of me figure out how to do it. I've done quite a bit of looking around but am still kinda new to this.
Any ideas?
You will have to make them block elements to be able to set a width:
.button {
display: block;
width: 100%;
}
Generally, these buttons are so-called "inline element". The browser renderer has very complex algorithms of layouting these elements. It's like Typesetting but with objects on your screen instead.
CSS and HTML together influence how the algorithm works: determining the width and height, color, etc. of objects. Also their position and how text flows, or how long buttons are.
There is a limitation, however. You cannot use anything that's like a variable width for inline elements.
Adding width: 100%; display: block as others suggested makes some buttons perfect: but only when they start at the left or right of the containing box. If it's after a sentence, then it (should) display as:
<---width of container--->
Text
<----------button-------->
However, the button is not after "Text" anymore, but is put below it. This is because it's now a so-called "block element". It is like a full paragraph, instead of elements in a text line.
If this is what you want; fine and problem solved. If this is not what you want, and instead want:
<---width of container--->
Text <-------button------>
This is not possible. CCS4 would be cool if it adds inline-width: 100% or inline-height, and solve a lot of problems. However CSS4 does not exists yet.
Adding width:100% to .button seems to work for the center and right buttons at the bottom of the page.

Resources