Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to vertically align iframe element inside table cell?

Featured Replies

I am trying to specify independent vertical alignment attributes for text and iframe elements contained within the same table cell but nothing I do seems to work. What I want is for the text to align to the top of the cell and the iframe (embedded Youtube link) to align bottom. Can this even be done, or should I split each table cell into two further cells? The HTML as it currently stands is below (CSS file is accessed remotely).

 

<td height="360">

<p class="q">

<span class="quote">“blah blah blah blah.”</span>

<br>- Ben Smith</p>

<iframe src="xxxxxxxxxxxxxxxxxxxxxxxxx" allowfullscreen="" style="float: left; margin-bottom: 5px;" frameborder="0" height="225" width="348"></iframe>

</td>

I'm sure you can't make one table cell have both vertical-align: top and vertical-align: bottom so it looks as if you will have to have a table cell on two rows possibly with zero cellspacing (cellpadding).

 

You could use div or display: table-cell instead of table cells but I think you would still need to use two.

Edited by Wickham

Could you upload your code any where

I'm also suspecting that you shouldn't be using a table here. But assuming that you are using it consciously (there are also some situations when this happens), here you go:

 

You can align the text to the top in the cell and position the iframe absolutlely and pull it to the bottom. For this to work, you will have have to assign a width to the cell, because the iframe won't occupy any space, and also position it relatively.

td{
  position:relative;
  height:360px;
  width:500px;
  vertical-align:top;
}
iframe{
  position:absolute;
  bottom:0;
}

Edited by ocorreiododiogo

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.