align headings to same baseline, regardless following text?

十年热恋 提交于 2019-12-01 04:13:22

The web handles baselines differently than you are used to in print. Browsers will align your text to the center of the line-height, rather than the bottom. This means text aligned to the web grid are vertically centered in relation to each other rather than sitting on the same baseline.

If you are OK with that, you can still get a strong grid from it. You just have to be exact with your combined use of line-height, padding, borders and margins. It takes some math, but is entirely possible. More here:

http://24ways.org/2006/compose-to-a-vertical-rhythm/

If you need things actually aligned to a baseline as you know it in print, the game is much more difficult. The problem is that you will need to push things various amounts depending on the exact font - hardly possible when each browser may be using a different font. Here is one attempt to make that possible:

http://baselinecss.com/

With either solution there are cross-browser problems. The web just doesn't offer the proper tools for this yet. But in no case should you need the divs. You can do all that adjustment on the headings themselves. You don't even need them in your example. Why are the divs there?

Just a quick thought (as in "I had this idea, that might work, but I didn't test it"): How about using line-height? You could use the same line-height for all headlines, thereby ensuring a uniform baseline on all lines.

Regards Jesper Hauge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!