Reputation: 1110
I am new to bootstrap, and I have to make an image circle in shape using bootstrap. When I add my own CSS for this image, it becomes an oval in shape. Following is the html and css for this.
CSS:
.person {
border: 10px solid transparent;
margin-bottom: 25px;
width: 80%;
height: 80%;
opacity: 0.7;
}
.person:hover {
border-color: #f1f1f1;
}
HTML:
<div class="row">
<div class="col-sm-4">
<p>
<strong>Test Member 1</strong>
</p>
<br />
<a href="#demo" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-circle person" alt="Band Manager" />
</a>
<div id="demo" class="collapse">
<p>Guitarist and Lead Vocalist</p>
<p>Loves long walks on the beach</p>
<p>Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p><strong>Test Member 2</strong></p><br />
<a href="#demo2" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-circle person" alt="Random Name">
</a>
<div id="demo2" class="collapse">
<p>Guitarist and Lead Vocalist</p>
<p>Loves long walks on the beach</p>
<p>Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p><strong>Test Member 3</strong></p><br />
<a href="#demo3" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-circle person" alt="Random Name">
</a>
<div id="demo3" class="collapse">
<p>Guitarist and Lead Vocalist</p>
<p>Loves long walks on the beach</p>
<p>Member since 1988</p>
</div>
</div>
</div>
Upvotes: 0
Views: 3662
Reputation: 67
Hi please check this solution it might be help you.
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.person
{
border: 10px solid transparent;
height: 200px;
width: 200px;
padding: 10px;
opacity: 0.7;
}
.person:hover
{
border-color: #f1f1f1;
}
</style>
</head>
<body>
<div class="row">
<div class="col-sm-4">
<p>
<strong>Test Member 1</strong>
</p>
<br />
<a href="#demo" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-responsive img-circle person" alt="Random Name">
</a>
<div id="demo" class="collapse">
<p>
Guitarist and Lead Vocalist</p>
<p>
Loves long walks on the beach</p>
<p>
Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p>
<strong>Test Member 2</strong></p>
<br />
<a href="#demo2" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-responsive img-circle person" alt="Random Name">
</a>
<div id="demo2" class="collapse">
<p>
Guitarist and Lead Vocalist</p>
<p>
Loves long walks on the beach</p>
<p>
Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p>
<strong>Test Member 3</strong></p>
<br />
<a href="#demo3" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-responsive img-circle person" alt="Random Name">
</a>
<div id="demo3" class="collapse">
<p>
Guitarist and Lead Vocalist</p>
<p>
Loves long walks on the beach</p>
<p>
Member since 1988</p>
</div>
</div>
</div>
</body>
</html>
Upvotes: 0
Reputation: 78840
These styles:
width: 80%;
height: 80%;
...don't set the width/height as relative to the current size. Rather, they set the width/height relative to the containing block. Thus, you're almost guaranteed to have the width and height not match.
You will need to use different sizing units other than %.
Upvotes: 1