2016-09-16 21 views
0

在響應中span未顯示完整背景。使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> 

回答

1

設置inline-blockspan,因爲span是內嵌元素

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