
The colors you specify will start at the starting point and end at the ending point. The colors of the gradient are defined by two or more points, the starting point, the ending point, and other optional points. This line can be vertical, horizontal, diagonal, or at any angle you will specify in the linear-gradient function. The colors that make the gradient are placed on this gradient line. Gradient line - A linear-gradient is defined by an axis called the gradient line. However, we can set the size of the gradient box using the background-size property of CSS then the gradient box will be resized and will be placed in the top left corner of the DOM element by default.Ģ.


When we apply a linear gradient to any Html element, that area is the border-box for that element which is the same area that would have been taken by any background image unless you change the size using other CSS properties. What gives a visible dimension to the gradient is the gradient box which is the area where it is displayed, i.e., around any HTML element.

Gradient Box - A gradient image has infinite dimensions, unlike other background images. This will be the default direction as depicted in the above image and is equivalent to the top to the bottom, which means the colors are distributed from top to bottom. However, the default direction is 180 degrees or from top to bottom. You can also state a direction in which the change of colors should happen. These are the colors among which you want a transition. To create a linear gradient, you should specify at least two colors. We can specify two or more colors to display the transition among them. The linear-gradient() function sets a linear gradient, a transition between colors along a straight line as the background image. Moreover, the gradient is generated by the browser itself, so they look better than raster images when zoomed in. This function can be used anywhere you would use an image, such as the background since gradients are generated dynamically, so they can be used instead of traditional raster images that give similar effects. Therefore, the linear-gradient() function results in an object of type. The linear-gradient() function creates an image that displays a transition in the form of two or more colors along a straight line.īasically, CSS gradients are represented by the data type, which is a special kind of image. The linear-gradient() function is an inbuilt function in CSS to set the linear gradient CSS as the background image. Therefore we use a linear gradient in which colors flow in a single direction from left to right, top to bottom, or at any angle the user specifies. It displays a transition of different colors that makes our website more attractive. Linear Gradient CSS displays a smooth transition between two or more colors along a straight line. Linear gradients change color in a linear fashion, while the radial gradients change color in a radial fashion. These are of two types-linear gradients and radial gradients. Gradients are basically color transitions where an area changes from one color to another. We will also discuss the different values the linear gradient function can take.The composition of the linear-gradient function- the gradient box, gradient line, and gradient angle has been explained.Then, we will learn about the linear-gradient function, its usage, and its syntax in detail.We will start with a brief introduction of the Gradients.In this article, we are going to learn about the following. We will be learning about them in detail in the article.

Gradients in CSS are of two types-Linear gradients and radial gradients. Sometimes we need to style our elements differently and make them attractive instead of just a solid color or an image.
#GRADIENT CSS GENERATOR#
The CSS Cheat Sheet has its own button generator where you can set up the styles of your button in an interactive interface.In CSS, we use the background-color property to set the background color of an element. Use the online gradient generator to set up buttons with your own color adient-button Īnd finally a screenshot image with the buttons for those who use outdated web browsers which don’t support CSS3 but still want to see how these gradient buttons look like: You can adjust the style sheet below according to your needs, changing the margins, padding and font size.
#GRADIENT CSS CODE#
Button 1 Button 2 Button 3 Button 4 The CSS code We set four links with a common gradient button class and assign a unique class with the color style. Try the onpage demo and see the focus position of the background travelling from one side to the other. Gradient background buttons with animated hover transition effect implemented with HTML5 and CSS3.
