我如何效仿HTML中的「<img align=top>」在CSS中?
<img align='top' src='huge_image.jpg'>
<span>I start at the top right corner of the image!</span>
在CSS?
也許這是令人尷尬的簡單,但我真的不知道。
我如何效仿HTML中的「<img align=top>」在CSS中?
<img align='top' src='huge_image.jpg'>
<span>I start at the top right corner of the image!</span>
在CSS?
也許這是令人尷尬的簡單,但我真的不知道。
這取決於你的元素的容器上。 vertical-align
CSS屬性不完全映射到valign
屬性。我建議檢查這個鏈接瞭解如何使用CSS實現這一點。 http://phrogz.net/CSS/vertical-align/index.html
謝謝大家;接受這個答案,因爲有很好的聯繫。 – 2009-11-13 00:20:43
@Pekka웃:如果只有人會*總結*鏈接在這裏.. – 2015-07-20 14:53:23
我認爲你正在尋找的vertical-align CSS屬性。
<img style="vertical-align: top;" alt="blah" src="blah.jpg" />
理想情況下,你將不只是直接拍它的<img>
標籤,而是使用一個CSS類。
float: left
將它定位使得img元素將是跨度的左邊,但如果你是想複製align="top"
因爲垂直對齊問題(在右下角與右上跨度)的,則儘量style="vertical-align: top;"
<style="text/css">
.top_aligned_image {vertical-align: top; /* or text-top, I can't remember for sure which works better */}
</style>
<img class="top_aligned_image" src='huge_image.jpg' /><span>I start at the top right corner of the image!</span>
應該這樣做。
不應該說「top_aligned_image」規則有一個「。」前面? – 2009-11-13 00:15:58
...呃...是的。是的,它應該。謝謝你=)(編輯和修改) – 2009-11-13 00:28:17
從來沒有使用過'ALIGN = 'top'' - 但不'ALIGN =' left''做同樣的事情? – warren 2009-11-13 00:00:24