Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey guys, so basically this is my html code

HTML
<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title>My Social Network</title>
	</head>
	<body>
	    <div class="friend"></div>
	    <div class="friend" id="best_friend"></div>
	    <div class="family"></div>
	    <div class="enemy"></div>
	    <div class="enemy" id="archnemesis"></div>
	</body>
</html>


and this is my CSS code

CSS
div {
	display: inline-block;
	margin-left: 5px;
	height:100px;
	width:100px;
	border-radius:100%;
	border:2px solid black;
}

.friend{
    border: 2px dashed #008000;
}

.family{
    border: 2px dashed #0000ff;
}

.enemy{
    border: 2px dashed #ff0000;
}

#best_friend{
    border:4px solid #00C957;
}

#archnemesis{
    border:4px solid #CC0000;
}


The result of the code are 5 circles with different borders around them each.

My question is how would I go about putting images into the circles, with the images being cropped to the dimensions of the already created circles/borders?
Posted

1 solution

Treat the image as background of the div and set the various background properties in CSS like this example:
CSS
div {
    */ your existing rules */
	background-image: url("http://codeproject.cachefly.net/App_Themes/CodeProject/Img/logo250x135.gif");
	background-repeat: no-repeat;
	background-position:50% 50%;
	background-size: contain;
}
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900