[英]Hiding effect of block of text with image as background! linear gradient of opacity?
[英]hiding overlapped text is failing in case of linear gradient
我正在嘗試此小提琴中顯示的代碼:
如果“ $ number”可以有任意數量的數字,並且我們不知道它的大小,因為如何從其他文件中獲取數字的數量,如何消除重疊。($ number是生成的隨機數)$ number必須具有不透明的背景這樣它下面的文本就不會顯示出來。(文本必須在$ number的左邊
html代碼是:
<div class="body">
<div class="variation font700 green">
<h2>
overflown text must be hidden and the visible text must be in single line
<span class="divider">
$number
</span>
</h2>
</div>
<div class="clear"></div>
</div>
當我們將背景作為單一顏色而不是漸變時,這非常完美,為什么呢,這是將小提琴與背景作為單一顏色的鏈接: http : //jsfiddle.net/Re9ZN/有人可以給嗎我提供了一個解決方案,以便當我們使用漸變色時效果很好。
以下代碼可以為您解決問題。
在您的CSS類中更改為:
.variation h2 span{
background: linear-gradient(to left, #339933,#003300);
position:absolute;
right:0;
}
演示 : http : //jsfiddle.net/Akki619/xzW6A/
對於您的評論編輯1
您可以使用以下代碼,請根據需要更新顏色。 它涵蓋了所有瀏覽器。
background-color: #F07575; /* fallback color if gradients are not supported */
background-image: -webkit-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For Chrome and Safari */
background-image: -moz-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Fx (3.6 to 15) */
background-image: -ms-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For pre-releases of IE 10*/
background-image: -o-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Opera (11.1 to 12.0) */
background-image: linear-gradient(to bottom, hsl(0, 80%, 70%), #bada55); /* Standard syntax; must be last */
注意:不能以您期望的方式預期答案,應將其視為“入門”。
下面這張圖片是最大的,我可以為您提供最大的幫助。 由於各節的划分,我認為當前的實現是不可能的。
CSS代碼:
background: #7fbf70; /* Old browsers */
background: -moz-linear-gradient(left, #7fbf70 0%, #76b868 1%, #73b766 2%, #60ac5a 4%, #48a04d 10%, #3c9a47 13%, #309643 19%, #289441 27%, #289341 41%, #168b3e 47%, #08893d 49%, #00853c 52%, #005b28 88%, #005424 96%, #005424 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#7fbf70), color-stop(1%,#76b868), color-stop(2%,#73b766), color-stop(4%,#60ac5a), color-stop(10%,#48a04d), color-stop(13%,#3c9a47), color-stop(19%,#309643), color-stop(27%,#289441), color-stop(41%,#289341), color-stop(47%,#168b3e), color-stop(49%,#08893d), color-stop(52%,#00853c), color-stop(88%,#005b28), color-stop(96%,#005424), color-stop(100%,#005424)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #7fbf70 0%,#76b868 1%,#73b766 2%,#60ac5a 4%,#48a04d 10%,#3c9a47 13%,#309643 19%,#289441 27%,#289341 41%,#168b3e 47%,#08893d 49%,#00853c 52%,#005b28 88%,#005424 96%,#005424 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #7fbf70 0%,#76b868 1%,#73b766 2%,#60ac5a 4%,#48a04d 10%,#3c9a47 13%,#309643 19%,#289441 27%,#289341 41%,#168b3e 47%,#08893d 49%,#00853c 52%,#005b28 88%,#005424 96%,#005424 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #7fbf70 0%,#76b868 1%,#73b766 2%,#60ac5a 4%,#48a04d 10%,#3c9a47 13%,#309643 19%,#289441 27%,#289341 41%,#168b3e 47%,#08893d 49%,#00853c 52%,#005b28 88%,#005424 96%,#005424 100%); /* IE10+ */
background: linear-gradient(to right, #7fbf70 0%,#76b868 1%,#73b766 2%,#60ac5a 4%,#48a04d 10%,#3c9a47 13%,#309643 19%,#289441 27%,#289341 41%,#168b3e 47%,#08893d 49%,#00853c 52%,#005b28 88%,#005424 96%,#005424 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7fbf70', endColorstr='#005424',GradientType=1 ); /* IE6-9 */
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.