Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 响应圆和圆上的图像拟合_Html_Css_Responsive - Fatal编程技术网

Html 响应圆和圆上的图像拟合

Html 响应圆和圆上的图像拟合,html,css,responsive,Html,Css,Responsive,我想创建一个反应灵敏的圆圈,我想适合图像。我想使用img标记而不是css(背景) 这是我试过的 .circular--portrait { position: relative; width: 200px; height: 200px; overflow: hidden; border-radius: 50%; } .circular--portrait img { width: 100%; height: auto; } <div class="circu

我想创建一个反应灵敏的圆圈,我想适合图像。我想使用
img
标记而不是css(背景)

这是我试过的

.circular--portrait {
  position: relative;
  width: 200px;
  height: 200px;
  overflow: hidden;
  border-radius: 50%;
}

.circular--portrait img {
  width: 100%;
  height: auto;
}

<div class="circular--portrait">
                <img src="img.jpg" />
            </div>
.circular——纵向{
位置:相对位置;
宽度:200px;
高度:200px;
溢出:隐藏;
边界半径:50%;
}
.圆形-纵向img{
宽度:100%;
高度:自动;
}
.circular——纵向{
位置:相对位置;
宽度:20vw;
高度:20vw;
溢出:隐藏;
边界半径:50%;
}
.圆形-纵向img{
宽度:100%;
身高:100%;
对象匹配:覆盖;
}

.circular——纵向{
位置:相对位置;
宽度:20vw;
高度:20vw;
溢出:隐藏;
边界半径:50%;
}
.圆形-纵向img{
宽度:100%;
身高:100%;
对象匹配:覆盖;
}


您可以尝试使用SCS执行此操作。您只需要创建一个变量

$width:calc(100vw/5);
.圆圈{
宽度:$width;
高度:$宽度;
背景:url('https://images.pexels.com/photos/17679/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=350');
边界半径:50%;
浮动:左;
保证金:5px;
}


您可以尝试使用SCS执行此操作。您只需要创建一个变量

$width:calc(100vw/5);
.圆圈{
宽度:$width;
高度:$宽度;
背景:url('https://images.pexels.com/photos/17679/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=350');
边界半径:50%;
浮动:左;
保证金:5px;
}


您可以尝试使用SCS执行此操作。您只需要创建一个变量

$width:calc(100vw/5);
.圆圈{
宽度:$width;
高度:$宽度;
边界半径:50%;
浮动:左;
保证金:5px;
背景:红色;
溢出:隐藏;
}


您可以尝试使用SCS执行此操作。您只需要创建一个变量

$width:calc(100vw/5);
.圆圈{
宽度:$width;
高度:$宽度;
边界半径:50%;
浮动:左;
保证金:5px;
背景:红色;
溢出:隐藏;
}

下面是一个解决方案,它让图像根据其父容器的宽度做出响应

.container{
/*请随意调整此处的值,以便您可以看到它的响应性*/
宽度:200px;
}
.圆圈{
位置:相对位置;
宽度:100%;
身高:0;
填充:100%0;
边界半径:50%;
溢出:隐藏;
边框:1px纯色灰色;
}
.圆圈img{
位置:绝对位置;
排名:0;
左:0;
宽度:100%;
身高:100%;
对象匹配:覆盖;
}

下面是一个解决方案,它让图像根据其父容器的宽度做出响应

.container{
/*请随意调整此处的值,以便您可以看到它的响应性*/
宽度:200px;
}
.圆圈{
位置:相对位置;
宽度:100%;
身高:0;
填充:100%0;
边界半径:50%;
溢出:隐藏;
边框:1px纯色灰色;
}
.圆圈img{
位置:绝对位置;
排名:0;
左:0;
宽度:100%;
身高:100%;
对象匹配:覆盖;
}



为什么不能使用背景?添加边界半径:50%;关于图像,问题是什么?您的代码工作它没有响应:(然后使用
background
-它解决了当使用标准
img
标记时更难解决的问题。为什么不能使用background?添加边框半径:50%;在图像上是什么问题?您的代码工作它没有响应:(然后使用
background
——它解决了在使用标准
img
标签时更难解决的问题。这是一个不错的解决方案,但图像看起来并不完美。宽度或高度更大。你可以改变this@Geor1947对不起,我没有马上明白你的意思。修正了很多汉克!太好了我想要什么。我有一个问题,什么是vw?使用vw比em或百分比好吗?@Geor1947“vw”-视口宽度的1/100。“vh”-视口高度的1/100。这是一个不错的解决方案,但图像看起来并不完美。宽度或高度更大。你可以更改this@Geor1947对不起,我没有马上明白你的意思。修正了很多问题!这就是我想要的。我有一个问题:什么是大众?使用大众比em或百分比好吗?@Geor1947“vw”-视口宽度的1/100。“vh”-视口高度的1/100。