How to use outside shape css

Hello guys today we will learn how to use outside shape css

First we need to create two files index.html and style.css then we need to do code for it.

Step:1

Add below code inside index.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Shape Outside css</title>
	<link rel="stylesheet" type="text/css" href="style.css">
	<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500&family=IBM+Plex+Serif:wght@300;400&display=swap" rel="stylesheet">
</head>
<body>
	<div class="main-content">
		<div class="container">
			<div class="shape-row shape-circle">
				<h1>Shape Outside CSS Circle</h1>
				<div class="grid">
					<div class="img-l circle"><img src="rahul.jpg"></div>
					<div class="img-r circle"><img src="ketty.jpg"></div>
					<div class="content-txt">
						<p>"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and are demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

Step:2

Then we need to add code for style.css which code i provide in below screen.

body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    font-family: 'IBM Plex Serif',Serif;
}
h1 {
    font-family: 'IBM Plex Sans',Serif;
    text-align: center;
    margin: 10px 0;
}
* {
	padding: 0;
	margin: 0;
}
.container {
	max-width: 600px;
	margin: auto;
}
.circle > img {
    width: 100%;
    display: block;
    shape-outside: circle();
}
.circle {
    border-radius: 50%;
    overflow: hidden;
    shape-outside: circle();
}
.img-r {
    float: right;
}
.img-l {
    float: left;
    max-width: 250px;
}
.img-r > img {
    max-width: 180px;
}
.shape-row {
    margin: 50px 0;
}

Output:

Leave a Comment