如何在border div
上放置一些文字,以便文字有transparent background
它與背後的圖像相匹配?div邊框透明背景上的文字
的問題是,background-image
有一些形狀和多種顏色,所以我不能把只是一些背景顏色的文本,因爲它不適合。
例子:
html,
body {
width: 100%;
height: 100%;
}
body {
margin: 0;
background: url(http://wallpoper.com/images/00/45/05/47/green-background-2_00450547.jpg);
}
#main {
margin-top: 100px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
border: 1px solid #000000;
}
#main h2 {
font-size: 60px;
font-weight: 700;
text-align: center;
margin: -40px 0 0;
background: transparent; /* somehow remove the border behind the text */
padding: 0 20px;
}
<div id="main">
<h2>Star players</h2>
<ul>
<li>foo</li>
<li>bar</li>
</ul>
</div>
@downvoter如果這是一個簡單的任務,請自由地發佈答案。 – Vucko
也許是這樣的http://jsfiddle.net/soledar10/uprkj7kj/ – Dmitriy
@Dmitriy這是一個很好的解決方案,但我可以,它不想'FF'中的文本對齊? – Vucko