这种效果css能实现吗,把背景切除一个半圆出来
你的问题没有抓不到重点。我观察你的截图总结如下:
理论上以下代码可以实现你说的效果,如下:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style>
body {
background-color: #ee0;
}
.hollow-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.hollow {
position: absolute;
width: 150px;
height: 150px;
border-radius: 100%;
border: 1000px solid rgba(0, 0, 0, 1);
top: 50%;
left: 50%;
margin: -1075px 0 0 -1075px;
opacity: .5;
}
.hollow::before {
content: '';
position: absolute;
top: -1px;
left: -1px;
width: 152px;
height: 152px;
border-radius: 100%;
border: 10px solid #000;
box-sizing: border-box;
/* 做一个渐变 */
-webkit-mask: linear-gradient(to bottom, rgba(0, 0, 0, 1), rgba(0, 0, 0, 1) 50%, rgba(0, 0, 0, 0));
pointer-events: none;
}
.hollow-after {
position: absolute;
top: 50%;
left: 50%;
width: 130px;
height: 130px;
border-radius: 100%;
border: 8px solid #fff;
box-sizing: border-box;
margin: -65px 0 0 -65px;
}
</style>
</head>
<body>
<div class="hollow-mask">
<div class="hollow"></div>
<div class="hollow-after"></div>
</div>
</body>
<script type="text/javascript">
</script>
</html>
效果如下:
不过,这是在我的机子上的截图。
<img src='imgdata' />
img{
width: 100px;
height: 100px;
border-radius: 50%;
display: block
}
3 回答5.1k 阅读✓ 已解决
5 回答1.9k 阅读
2 回答1.9k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
3 回答2.4k 阅读
4 回答2.2k 阅读
3 回答2.1k 阅读
我有一种实现方式,先画一个圆,再用其他元素遮挡住一半,剩下就是半个圆了,看代码吧