使span标记显示完整背景,而不是包含在响应中

时间:2016-09-16 11:11:53

标签: html css responsive

在响应中span未显示完整背景。

它显示适当的高达836像素后,它包裹在另一行,我希望只包装文本而不是背景。

如何显示完整背景?



span{
  background: red;
  color: white;
  padding: 50px;
  border-radius: 5px;
  text-align: center;
  font-family: arial;
  font-size: 20px;
}

<span>In responsive span is not showing full background. How to show full background?</span>        
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

inline-block设置为span,因为span是内联元素

&#13;
&#13;
span{
  background: red;
  color: white;
  padding: 50px;
  border-radius: 5px;
  text-align: center;
  font-family: arial;
  font-size: 20px;
  display:inline-block
}
&#13;
<span>In responsive span is not showing full background. How to show full background?</span>
&#13;
&#13;
&#13;