如何设置SPAN的高度属性 [英] How to set height property for SPAN

查看:207
本文介绍了如何设置SPAN的高度属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用预定义的高度来使以下代码可伸展。

I need to make following code stretchable with predefined height

<style>
.title{
   background: url(bg.gif) no-repeat bottom right;
   height: 25px;
}
</style>

<span class="title">This is title</span>

但由于 span 是内联元素,height工作。

But since span is inline element, "height" property won't work.

我尝试使用 div ,但它会展开到上层元素的宽度。宽度应灵活。

I tried using div instead, but it will expand up to the width of upper element. And the width should be flexible.

任何人都可以为此提出任何好的解决方案?

Can anyone suggest any good solution for this?

提前感谢。

推荐答案

在CSS中给它一个 display:inline-block

在兼容性方面:IE6 / 7 使用此功能,因为怪异模式建议:

Give it a display:inline-block in CSS - that should let it do what you want.
In terms of compatibility: IE6/7 will work with this, as quirks mode suggests:


IE 6/7只接受自然显示的元素的值:inline。

IE 6/7 accepts the value only on elements with a natural display: inline.

这篇关于如何设置SPAN的高度属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆