当图像尺寸被改变时,如何在图像周围制作圆形边框而不是椭圆形?

问题描述 投票:0回答:1

正如标题所说,我想在我的图像周围添加一个圆形边框,我已经知道了

border-radius: 50%;

但是由于我的图像尺寸发生了变化,所以它变成了一个椭圆。那么如何在我的图像周围放置一个圆形边框呢?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
    <title>Visit Citrus County</title>
</head>
<body>
    <div class="block1">
        <h1 id="title">Welcome to Citrus County</h1>
        <h2 id="sub-title"> Home of the Manatees, and Great Wildlife!</h2>
    </div>
    <div class="block2">
        <h1 id="things"> Top Three Activites to do in <span id="citrus-county">Citrus County.</span></h1>
        <div id="activites">
            <img id="kayaking" src="images/kayaking.jpg">  
            <img id="swim" src="images/swim-with-manatee.jpg">
            <img id="hike" src="images/hiking.jpg">
            
        </div>
    </div>
</body>
</html>
[Code ->](https://jsfiddle.net/uo07xthy/)

html css web-testing
1个回答
0
投票

给出图像宽度和

aspect-ratio:1
.

img {
  width: 200px;
  border-radius: 50%;
  aspect-ratio: 1;
  border: 1px solid red;
}
<img id="kayaking" src="images/kayaking.jpg">

© www.soinside.com 2019 - 2024. All rights reserved.