除非输入文本,否则不显示span的宽度和高度 [英] width and height for a span does not show up unless a text is entered

查看:96
本文介绍了除非输入文本,否则不显示span的宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有< span id =some>< / span> ,css是

  #some {
background-color:#000; width:150px; height:50px;
}

除非输入内容,否则不显示宽度和高度。

$ <$> 是一个内联元素,因此不告诉浏览器其显示属性为阻止,您将无法正常工作。



简单来说:

  #some {
background-color: 000;
width:150px;
height:50px
display:block;
}

希望它有帮助,Sinan


I have a <span id="some"></span> and the css is

#some{
      background-color:#000; width:150px; height:50px; 
}

The width and height does not show unless something is entered. How can i fix this?

解决方案

span is an inline element, so without telling browser that its display property as block what you do won't work out.

So in brief:

#some{
  background-color:#000; 
  width:150px; 
  height:50px; 
  display: block;
}

Hope it helps, Sinan

这篇关于除非输入文本,否则不显示span的宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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