简体   繁体   English

如何使垂直线从线的顶部到底部改变不透明度

[英]How can I make a vertical line change opacity from top to bottom of a line

I want to make a line which should change its opacity along the line from one end to another using HTML or CSS or JS. 我想制作一条线,使用HTML或CSS或JS将其不透明度从一端更改为另一端。 The line should start with less opacity and should end with high opacity or vice versa. 该行应以较低的不透明度开始,并应以较高的不透明度结束,反之亦然。

or 要么

The line should start and end with less opacity and should have high opacity in the middle of the line. 该行应启动和更低的透明度结束,并应在该行的中间高不透明度。

在此处输入图片说明

Essentially, what you need is a gradient line. 本质上,您需要的是一条渐变线。 Here's an example of such a CSS: 这是此类CSS的示例:

hr.name-of-your-vertical-line {
  border : 0;
  height : (height)px; /*your own value to suit your content*/
  width : 1px;
  background-image: -webkit-linear-gradient(top, #color1, #color2, #color3);
  background-image: -moz-linear-gradient(top, #color1, #color2, #color3);
  background-image: -ms-linear-gradient(top, #color1, #color2, #color3);
  background-image: -o-linear-gradient(top, #color1, #color2, #color3);
  background-image: linear-gradient(top, #color1, #color2, #color3);
}

You can read more about gradients here 您可以在此处阅读有关渐变的更多信息

Here's a JSFiddle example you can look at 这是一个JSFiddle示例,您可以看一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过文本输入更改SVG行的不透明度? - How can i change the opacity of my SVG line with a text input? 如何使顶线短于底线(在div内) - How to make top line shorter than bottom line (within div) 如何在d3.js中将X轴线从顶部更改为底部 - How to change the X-axis line from top to bottom in d3.js 来自元素底部的Javascript垂直线 - Javascript vertical line coming from the bottom of an element 我怎样才能重写这段代码,使 object 从 canvas 的顶部掉落,当到达底部时它会重置到顶部 - how can i rewrite this code to make an object fall from top of canvas and when hits bottom it resets at top 如何在谷歌图表中更改行不透明度? - How to change Line Opacity in google charts? 如何使HTML5画布进度栏从下至上而不是从上至下填充? - How can I make this HTML5 canvas progress bar fill from the bottom up instead of the top down? 是否可以更改 swiper 滑块中的方向垂直滑块? 我想要从上到下和从下到上的选项? - Is it possible to change the direction vertical slider in swiper slider? I want to have both top to bottom and bottom to top option? 我怎样才能在 tradingview 图表库上画一条直线垂直线 - How can i draw a straight vertical line on tradingview chart library 如何使所有滑块都在一条垂直线上? - how to make all of the sliders in one vertical line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM