最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

JavaScript, CSS: Clip to be inside parent DIV - Stack Overflow

matteradmin6PV0评论

Context

I have a bunch of nested DIVs (implementing a simple window system, for learning purposes, with DIVs).

Problem:

Let divA = child of divB.

Now, ideally, I want the contents of divA to be "clipped" inside of divB.

Thus, if I take divA, and drag it to the right ... as it gets out of the border of divB, I want the parts of divA that are outside of divB to be chopped off and not displayed.

Question:

How do I do this? How do I use one div to clip / mask another div?

Thanks!

Context

I have a bunch of nested DIVs (implementing a simple window system, for learning purposes, with DIVs).

Problem:

Let divA = child of divB.

Now, ideally, I want the contents of divA to be "clipped" inside of divB.

Thus, if I take divA, and drag it to the right ... as it gets out of the border of divB, I want the parts of divA that are outside of divB to be chopped off and not displayed.

Question:

How do I do this? How do I use one div to clip / mask another div?

Thanks!

Share Improve this question asked Jul 6, 2012 at 8:08 user1311390user1311390
Add a ment  | 

2 Answers 2

Reset to default 6

It's called:

.divA {
    overflow: hidden;
}

w3 schools

Use the css overflow property. Follow this link to see what values there are for overflow

Post a comment

comment list (0)

  1. No comments so far