如何让div淡出
你能告诉我如何使用 css 或 JavaScript 使效果淡出到文本或任何 div 的左侧吗? 效果如下所示:
在 html 中:
<div class="buttonBackground">
<div class="divToFadeOut">asdasdasdasdasdasdasd</div>
</div>
Can you tell me how can I get the effect fade out to left of text or any div using css or JavaScript?
The effect looks like here:
In html:
<div class="buttonBackground">
<div class="divToFadeOut">asdasdasdasdasdasdasd</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只想淡出 div 内的字母,那么您需要创建一个大约 20-30px 宽的 png-32,然后应用一些 CSS 将其固定在右侧。 CSS 来了。
在您选择的图像编辑器中,对宽 30 像素、高约 100 像素的图像应用渐变(不太重要)。左侧将是透明的,并且将与右侧的背景相匹配。这会有点棘手......因为这也是一个垂直渐变。
If you're wanting to just fade out the letters inside the div then you want to create a png-32 that's about 20-30px wide then apply some CSS to fix it to the right. CSS coming.
In your image editor of choice apply a gradient to an image that's 30px wide and about 100px high ( less important ). It will be transparent on the left side, and it will match the background on the right. That will be a little tricky... as that's also a vertical gradient.
你根本不需要任何 JavaScript。看起来,如果您指定一个带有文本的 div(并给它一个宽度,隐藏溢出),以及按钮的背景图像,然后指定另一个分层在文本上的图像,并且不透明度从 0 移动到 1从左到右,你就会得到这样的效果。
You dont need any javascript at all. It seems that if you specify a div with the text (and give it a width, overflow hidden), with a background image of the button, and then specify another image layered over the text with the opacity moving from 0 to 1 as you go left to right, you would get that effect.
即可实现:
无需更改 HTML,应用以下 css
It can be achieved without changing the HTML
apply the following css: