• 0

Aligning text to the base of it's parent


Question

Hi there,

I've got the following problem. I have an <h3> parent element with an <a> child. The <h3> has fixed height and width. I would like the child <a> to be positioned at the bottom of the parent.

The html:


&lt;h3&gt;&lt;a href=""&gt;This is short&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=""&gt;This is a long one that should run two lines&lt;/a&gt;&lt;/h3&gt;

The CSS:


h3 {
width: 200px;
height: 100px;
border: 1px solid red;
}
[/CODE]

What I currently see:

S75POxx.png

What I'd like to see:

hEwKEZt.png

And I would like to achieve it without using [i]display:table [/i]or [i]position:absolute.[/i]

Any help is much appreciated.

Thanks,

Jordan

4 answers to this question

Recommended Posts

  • 0

I've been trying to avoid using display:table but then that's what I keep seeing everyone say to use :/ ... I guess that's just what I'll do. Thanks.

Actually. What would be better for mobile support? display:table or position:absolute; bottom:0;

  • 0

Not sure to be honest, both should work fine.. although using positions may have better support on ie6 from what I've read.

http://jsfiddle.net/fgsdj/1/

^ using positions there, tested both on my nexus 4 default browser and both work fine

P.S sorry only just read you'd like to achieve it using neither of the above, missed that part

  • 0

display:table is perfectly fine. it's a stylistic rather than symantic declaration. what you want to avoid is using actual <table>s in the markup where the content isn't actually tabular data, but you can use CSS to tell browsers to treat things like tables for the purpose of styling all you want. all modern browsers support this, try it out on a phone to be sure but they should work just fine.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Give Elon Musk, who illegally had access to citizen's data, even more of your data ! Top idea !
    • An oldie but a goodie
    • I did that to a work colleague many years ago when he left it logged in. Unfortunately I was out of the office the next day, and even the IT department was stumped lol. Got a bit of a bollocking when I got back into the office, but, by god, it was worth it.
    • 7-Zip 26.02 by Razvan Serea 7-Zip is a open source file archiver with a high compression ratio. The program supports 7z, XZ, BZIP2, GZIP, TAR, ZIP, WIM, ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, RAR, RPM, SquashFS, UDF, VHD, WIM, XAR, Z. Most of the source code is under the GNU LGPL license. The unRAR code is under a mixed license: GNU LGPL + unRAR restrictions. Check license information here: 7-Zip license. You can use 7-Zip on any computer, including a computer in a commercial organization. You don't need to register or pay for 7-Zip. The main features of 7-Zip are: High compression ratio in 7z format with LZMA compression Compression ratio for ZIP and GZIP formats: 2-10 % better than the ratio provided by PKZip and WinZip Strong AES-256 encryption in 7z and ZIP formats Self-extracting capability for 7z format Integration with Windows Shell Powerful File Manager Powerful command line version Plugin for FAR Manager Localizations for 74 languages 7-Zip 26.02 changelog: Some bugs and vulnerabilities were fixed. Download: 7-Zip 26.02 (64-bit) | 1.6 MB (Open Source) Download: 7-Zip 26.02 (32-bit) | 1.3 MB Download: 7-Zip 26.02 (ARM64) | 1.5 MB View: 7-Zip Website | Release Notes | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Week One Done
      xvvxcvv earned a badge
      Week One Done
    • One Month Later
      xvvxcvv earned a badge
      One Month Later
    • Enthusiast
      Xonos went up a rank
      Enthusiast
    • Conversation Starter
      Admir earned a badge
      Conversation Starter
    • First Post
      The_Focal_Point earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      400
    2. 2
      +Edouard
      170
    3. 3
      PsYcHoKiLLa
      127
    4. 4
      neufuse
      69
    5. 5
      Xenon
      66
  • Tell a friend

    Love Neowin? Tell a friend!