Masking and Clipping on the Web

Masking and Clipping on the Web

Using Overflow

Code

.rect {
	width: 200px;
	height: 200px;
	background-color: #eaeaea;
	overflow: hidden;
	margin: 0 auto;
}
.circle {
	width: 200px;
	height: 200px;
	border-radius: 100px;
	background-color: #601785;
	position: relative;
	left: 100px;
}

Using Clip

Code

.circle {
	width: 200px;
	height: 200px;
	border-radius: 100px;
	background-color: #601785;
	position: absolute;
	clip: rect(0px,100px,200px,0px);
	margin: 0 auto;
}

Using Background Clip

Galaxy

Code

h1 {
	font-family: Arial;
	font-size: 5em;
	text-align: center;

	background-image: url(Galaxy.jpg);

	-webkit-background-clip: text;
	background-clip: text;

	color: rgba(0,0,0,0);
}