我是bootstrap的新手,我必须使用bootstrap制作一个形状为圆形的图像。当我为这个图像添加自己的CSS时,它变成了椭圆形。以下是html和css。
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>
答案 0 :(得分:0)
这些风格:
width: 80%;
height: 80%;
...不要将宽度/高度设置为相对于当前大小。相反,他们设置相对于包含块的宽度/高度。因此,您几乎可以保证宽度和高度不匹配。
您需要使用%以外的其他尺寸单位。
答案 1 :(得分:0)
您好,请检查此解决方案,它可能对您有帮助。
<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>
&#13;