2013-08-28 39 views
0

這可能是一個簡單的問題。我有一個背景顏色的標題文本。文本停止時背景顏色停止。我想要背景填充容器的整個長度。橫跨集裝箱拉伸的文字背景

<body> 

<div class="container"> 
    <p><span style="color:#ffffff; font-size:30px; background-color:#e12025;">I want the background- color stretched across the container</span> 
</div> 

</body> 

CSS:

body { 
background-color:#e12025; 
align:center; 
font-family:sans-serif; 
color:#000000; 
font-size:28px; 
} 

.container { 
background-color:#ffffff; 
position:relative; 
margin-left:auto; 
margin-right:auto; 
height:1785px; 
width:900px; 
border-style:none; 
padding:10px; 
} 

下面是一個例子:http://mm2.co/background-color

回答

0

嗯...

.container { 
    display: block; 
} 

1

如果你想在集裝箱跨容器「拉伸」的一切,取出容器內的填充:

.container { 
    padding:10px; /* remove this */ 
} 

如果你仍想保留頂部/底部填充的容器,這樣做而不是:

.container { 
     padding:10px 0px; /* add the 0px */ 
    } 

而且,你會想使跨段的顯示 -

添加/更改此:

<span style="display:block;">text here..</span>