I'm new to illustrator and graphic design, and attempting to learn my way around gradients by recreating some designs. I'm trying to replicate this effect like the one in the image below, and I feel like I've gotten 80% of the way there, but it feels as though something is missing. For example I understand how to create the fading effect from top to bottom, but how can you achieve the opacity on the sides? Also, in the second object, there's a second color inside the gradient that I've found impossible to replicate. Looking for some insight, and thanks in advance.
I don't see any "second color" you elude to. I think it's just a visual anomaly due to the line spacing and surrounding elements (perhaps some artifacts in the jpg.)
I also don't think there are any gradients on the lines. I think they are merely a solid color fill and an opacity mask is actually doing all the "fading".
The short answer....
A detailed explanation can be found in Illustrator's help files here: https://helpx.adobe.com/in/illustrator/how-to/illustrator-opacity-masks-transparency.html
The longer, perhaps more specific, answer...
Create a shape on top of your artwork which encompasses what you want to be visible. Fill that shape with the
Important Note because this shape will be a mask, using the
Registrationswatch is preferred so the shape will mask all colors 100%. Normally one would never use the
Registrationswatch for any artwork to be reproduced. Simply put,
Registrationonly because if usage as described here, otherwise never use the
Registrationswatch. Using the
Blackswatch, although it looks the same, can fail to hide 100% of all colors on a mask.
Create "soft" edges on that top shape. how you create soft edges is up to you. It can be done with gradients, gradient meshes, an embedded raster image, or a filter. The shape needs to "blend" between the
Registration color and either white or transparency.
Select the art and the top shape and on the Transparency Panel click
Invert Mask if necessary, and/or untick
Clip if necessary.
The top shape should now be a mask on the base artwork.
Visual representation which may be easier to follow....
What often throws users off here is further editing. The Transparency Panel has 2 little thumbnail images on it... you must click the mask thumbnail to edit the actual mask shape or object. Then you must click the art thumbnail on the panel to edit anything which is not the mask.
Above, I clicked the mask thumbnail, then increased the Feather amount. Then I clicked the artwork thumbnail to continue drawing anything else.
If you fail to click the artwork thumbnail, and continue drawing other, even unrelated, objects, those new object will be part of the mask (and often not directly visible which can really confuse users).
Using things like a Gradient Mesh for the mask shape will offer much more control than simple effects, such as
And using raster images will work as well...
Be aware though, raster images are raster and will be bound by all the traditional restraints raster images come with. Using a raster image on a mask doesn't change its nature. Its no different than using a raster image in the artwork - scaling/distorting rasters in Illustrator, even if they are on an Opacity mask, can lead to "broken pixels".
Like all masks, 100% black (or Registration) will hide portions of the artwork and 100% white will show portions of the artwork. Ticking the
Invert Mask option on the Transparency Panel reverses these.