Cutting things out
Sometimes we want to hide things for a minute or forever. In this lesson, we will take a look into the process of clipping out images and hiding overflowing text.
Video Transcript
00:00We're getting near to the end of this title in this last chapter. It's about
00:06Injecting content or controlling content from above we're gonna start from something relatively simple and very fun
00:12which is clipping and
00:14Basically containing elements making sure that only what we want of an element will be visible at any given time
00:21From one level of clipping where we're actually cutting it and masking it to just hiding the information
00:27Making it scrollable or not, but then this lecture you'll know how to do both. So let's jump right into it
00:32We're in site number four right now
00:35So just make sure that you have it and really all I did is took the sample that we had before and made this paragraph
00:41Have no formatting. So it's basically scrolling all the way through what I wanted to talk about is about masks in general
00:48And we're gonna be talking about two properties the overflow property and the clip property now
00:54You could use them both on for images and for
00:59Text so we're gonna focus on text because that's a less commonly used way of working with
01:05The type of manipulations, so I'm gonna go ahead into my source files searching for that paragraph
01:11and I'm gonna search for my multi paragraph because that is the paragraph that
01:16Doesn't have basically wrap anymore. The white space is no wrap and I'm gonna go ahead and add to it a
01:24Overflow and
01:26Set that to be hidden
01:28By setting the overflow to be hidden and by the way, the default is visible by setting it to be
01:34Hidden. I'm basically getting rid of anything that goes out of the bounds of the box of our paragraph
01:39And that bounds is defined by our paragraph that we created earlier where we set our width and height
01:45There was a minimum with a minimum and so on and so forth
01:48So if I go ahead here and I just click on refresh and I go ahead and refresh my item
01:55We'll see that now the paragraph is getting cut off and there's no way for us to see the remainder of the text
02:00It's completely invisible. No way to scroll nothing of the sort which leads me to the next way of working with it
02:07Is instead of setting it to be hidden setting it to be scroll now when we set it to scroll
02:12Basically, what will happen is by default the browser
02:16Based on whatever scrolling mechanism it has would add a scrolling mechanism to it in some browsers such as this one
02:23It's invisible unless you
02:25Roll over it and start moving around and then you'll have access to your scroll bar
02:30But in general even if you don't see it the content itself would be scrollable with your mouse
02:35Or if you dragged along the copy the copy itself would then move around with you
02:41So that's more or less the features of overflow
02:44There's one more which is called auto which I would avoid basically which basically lets the browser itself decide what to do
02:52We don't like giving the browser that type of decisions
02:55We want to control our design
02:57But in this case if we set the overflow to be automatic in this case
03:01What would happen is basically we would get a scroll bar because the browser would be smart enough to know that
03:07Not all of the content is visible and it would set it automatically
03:11But in general we would avoid auto. I would pick it manually our default as we said was visible
03:17So let's move on to another topic and kind of a relatable content topic
03:22what happens if you want to basically mask content or basically clip out content and as
03:28The name implies clipping is there's a property called clip now
03:33This only works with if your positioning is absolute or fixed
03:38It's not does not work with relative pathing now in this case in our footer our footer is positioned in that way
03:44So I'm going to go ahead and clip it
03:46Now clipping works very simply since CSS 2.1 the only valid shape is rectangle
03:55But they're expected to add more or we hope that more will be added in CSS 3 and beyond
04:00So right now there's only a rectangle
04:03But we're more or less this design is preparing us for the future where there might be circles and other types of shapes
04:08The rectangle go accepts four parameters the top right bottom and left for positioning
04:14I'm going to go ahead and just set the values because I already pre-configured the values that I want there
04:2353 and
04:2520 pixels so if I go ahead here and just click on a refresh
04:29we'll see that now our footer is going to be floating and it's going to be cropped in that specific position, so our
04:36Footer is not as overwhelming maybe even and if I go and inspect my footer
04:41We'll see that in my footer itself
04:42We could play around with those properties or if if 20 controls the top and I reduce that number it would go up up
04:49Until the top of the properties really matter minus in this case. There's nothing there
04:53So it wouldn't really affect anything so we could go up and down with it 20 set it's in that position
04:58The the second parameter as you can see is controlling
05:03The side the third parameter controls the bottom the last parameter controls the beginning point and really in in
05:13If you read a technical doc you it's going to tell you that it's going to be the top
05:17Right bottom left, but just go ahead and play with it and find the configuration that it looks best for you
05:22That's the easiest thing to do when it comes to clipping
05:26One thing that you might do by mistake is if you put the numbers in correctly you just won't see anything
05:30so start from really big values start from a zero here and
05:35not zero on this end
05:37but a really large number on the second parameter and a really large number and the third parameter and a small number in the
05:44Last parameter and then play around with the parameters until you find exactly the bounds that you want which is exactly what I did
05:50So that's it about clipping and that's it about
05:54overflows and we're going to continue on and continue exploring
05:59Overall overarching things that you could do to elements and CSS
