Html 带图像偏移的CSS圆形图像
是否可以创建内部带有圆圈和图像偏移的图像的div? 例如,如果我有一个高度为1200px的图像,我想用CSS创建一个100x100像素的圆,这个圆的初始x位置必须为500px?试试这个Html 带图像偏移的CSS圆形图像,html,css,Html,Css,是否可以创建内部带有圆圈和图像偏移的图像的div? 例如,如果我有一个高度为1200px的图像,我想用CSS创建一个100x100像素的圆,这个圆的初始x位置必须为500px?试试这个 .circleimg { border-radius: 50%; width:100px; height:100px; background-color:purple; background-position:500px 0; } HTML 这是您的问题的尝试
.circleimg {
border-radius: 50%;
width:100px;
height:100px;
background-color:purple;
background-position:500px 0;
}
HTML
这是您的问题的尝试执行,请参考您可以使用
100x100像素和初始x位置500px
<!DOCTYPE html>
<html>
<head>
<style>
div
{
border:2px solid #a1a1a1;
padding:100px 100px;
background:#dddddd;
width:300px;
border-radius:500px;
}
</style>
</head>
<body>
<div> Circle image for Moldaone </div>
</body>
</html>
div
{
边框:2px实心#A1A1;
填充:100px 100px;
背景:#dddddd;
宽度:300px;
边界半径:500px;
}
Moldaone的圆形图像
您可以尝试以下方法:
CSS:
HTML:
这是一个演示,演示了您的定位示例,div背景填充到图像的宽度和高度以及指定的大小
HTML
您可以通过以下方式实现:
SCSS
HTML
在我看来,这种方式更优雅。所以你想将图像的高度从1200px缩放到100x100?好的。我有一张1200px 1200px的图片,我想从这张图片中显示圆圈,但我想从固定位置获得这个圆圈,例如500 x和200 x yOkie-这是我的演示-看看它-有你的规格。
<!DOCTYPE html>
<html>
<head>
<style>
div
{
border:2px solid #a1a1a1;
padding:100px 100px;
background:#dddddd;
width:300px;
border-radius:500px;
}
</style>
</head>
<body>
<div> Circle image for Moldaone </div>
</body>
</html>
#circle {
width: 100px;
height: 100px;
border-radius: 50%;
border: 4px solid red;
background-image: url('IMAGE-URL-HERE');
background-position: 500px, 200px;
}
<div id="circle"></div>
<div></div>
div {
background-color: red; /*to show circle in demo */
background-image: url("");
background-size:contain;
/* contain scales image to largest size and makes it fit inside the content area. */
background-position: 500px 200px;
border-radius: 50%;
height: 1200px;
width: 1200px;
}
.rounded-circle {
border-radius: 50%;
height: 2.5em;
width: 2.5em;
}
<img class="rounded-circle"
src="image-route"
alt="">