gpt4 book ai didi

html - 创建不固定宽度和高度的圆形图像边框

转载 作者:搜寻专家 更新时间:2023-10-31 08:25:22 26 4
gpt4 key购买 nike

我有这样一张图片:

enter image description here

我只想显示绿色区域并 overflow hidden :

enter image description here

一模一样的吹图:

enter image description here

问题是图像显示如下:

enter image description here

html文件中的图片(非背景图片);

这是 html 文件:

<div class="thumb">
<img class="img-responsive" src="/image/25085">
</div>

CSS 文件:

.jbTourItem img {
width: 100px;
border: 4px solid #eee;
border-radius: 50%;
margin-right: 15px;
}

最佳答案

如果您不想指定图像的宽度和高度,但知道您想要的圆圈的大小,我过去常常这样做。

CSS

.circle {
border-radius: 50%;
height: 118px;
overflow: hidden;
position: relative;
width: 118px;
}

.center {
position: relative;
padding-left: 50%;
}

.thumb {
position: absolute;
left: -50%;
}

HTML

<div class="circle">
<div class="center">
<img src="http://i.stack.imgur.com/nByPB.jpg" class="thumb">
</div>
</div>

关于html - 创建不固定宽度和高度的圆形图像边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38954066/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com