Hello and welcome to another new episode of Learning Simplified.
In this tutorial we are going to learn about CSS filter effects.
In our previous tutorial we had learnt about how to blend images.
In that essence we had learnt about how to blend between a base color and a particular
image, and another thing that we had learnt about how to blend between two images; but
these things are all based upon some kind of background images; that means, in case
of blending two images we had introduced a background image and then we have blended
it with respect to another base color, or with respect to another image.
But, in case of CSS filter effects, we need to import our images as an image source and
then we need to create all those CSS filter effects, we need to impose all those filter
effects in order to get the desired result.
But, what is the basic difference between a background image and an image source? we
can see that in case of our previous tutorial, we had used this particular class here, this
image_blender, and in this particular div we have imported all those particular images
as a background image and then we have used them against it.
that means, if we get back to index.html, we can see that this is a div class image_blender
and there's nothing at all inside it.
If we put something like this one 'Hello World'; then if we press CTRL + S, get back to our
project and reload; we can see that here comes the text and it is practically imposing on
the background image.
That means, in this particular case, the image is acting as a background.
But in case, while we are using a particular image as an image source here; It is practically
a different image tag that we would be using something like this one.
This is an image tag and if we bring on an image here, for say, this one... we need to
provide an alt tag; so this is an alt tag that will be acting as a placeholder.
In case if your image doesn't load into the user's machine, the text which is attributed
against this alt tag, that will be shown in that place.
So we are providing this alt tag here as nature and we are providing a title which we will
be terming as, nature.
And another thing, this image source, this image tag, it is practically an open tag or
empty tag.
That means it has a definite starting, but it has no ending.
Something like this one, as we have seen in our previous cases - it doesn't end like this,
but instead, sorry; it does not end like this one but instead it ends as it is being shown
over here.
So this is the first thing that in case of background image we need to rely on div and
there's no additional modification we have to make in our main html page; but in case
of an image source we need to provide a separate URL; provide a separate relative path for
that particular image and it should be called in to our main .html page.
In the second case, if we look into stylesheet.css, it practically relies on the div and that
is why it practically depends on the available height in that particular div.
No positive dimension specification can be made in case of a background image.
That means we have to provide additional height or additional padding thing in order to make
a particular image visible into that particular div.
But in case of a particular image source, we need to provide a particular image into
our index.html or any HTML page and that is why we can mention a particular dimension
into that particular div element.
That means we can specify a particular dimension to that particular image whenever you may
apply it.
You can provide it over here; such as this one; if we provide here this particular width
attribute; or if we provide here a particular height attribute; anything can be attributed
in the index.html page; it is possible both over here; or, instead, we may get back to
stylesheet.css and we may specify it over here.
Both of them will be discussed; but first of all, all we need to do, we need to press
CTRL + S, get back to our project and reload; and we can see that the image source is right
now present into our HTML page but it is far way wider than the browser itself.
So, why it is?
Let's try to find out this problem into our image source.
we can see actually that this is the image source; this is the nature.jpg and if we hover
our mouse over here, we can see that this is the dimension of 1920 X 1080px.
That means this image is practically 1920px wider and 1080px in height.
And, we never mention any kind of dimension over here; so that is why we will be getting
this kind of output; but if we want to restrict this particular image into a particular definition
then all we need to do we need to get back to our project and here, either in this index.html
where we are currently working, we can specify this particular width to be of 1000px; and
the height, it should be restricted within 500px.
Now if we press CTRL + S and get back to our project and reload, we can see that 1000px
is the width which is still wider than the mother container that is currently wrapping
all the elements inside; so in that particular case all we need to do, we need to restrict
it within this 900px; Reload and we can see right now that the image is practically residing
into our div element.
On the other hand if we wish that we do not like to provide any kind of dimension specification
into this particular index.html; instead, all we can do, we can get back to stylesheet.css;
first of all, reload and you can see that the image is restored its original dimension,
its original width and height into this image-holder; All we are going to do.... we will be creating
this particular syntax over here; it is practically representing that the image tag, which is
present inside this particular selector name image-holder; it will be having these following
properties: such as, it will be having a width of 900px; It will be having a height of auto;
it will be float in...you may keep it afloat in the left side or in the right side; or
you may choose this particular none; so if we choose none; and up to this, if we get
back to our project and reload, we can see that this will be the result.
That means, we can customize an image source both in .HTML page, and in case of a CSS page.
If we do not wish to provide any kind of margin over here, then let's get back to our image-holder,
this main parent div over here and here we can provide the text-alignment, which should
be, center.
Get back to your project, reload and you can see that the image is actually residing into
the central position.
So these are the two points that we need to know about; the basic difference between a
particular image source and a particular background image.
So, in case of background image, we can put an image as a background of a particular div
element and in that case it will be relying entirely upon the properties of that particular
div and the height and the width - dimensional attributes of that particular div.
But in case of an image source we can define this particular dimension anywhere either
in the index.html page or any kind of HTML page where we are practically using this image;
or, we can define that particular dimension into the css page of that concerning parent
div.
So this is the thing in the first case.
We have now successfully introduced an image into a particular div element; the next thing
is, applying some kind of CSS filter effects, such as this contrast, hue-rotation, saturate,
or sepia tone, or just adjusting the brightness or lightness........
Không có nhận xét nào:
Đăng nhận xét