html - IE 的 CSS 剪辑路径替换
问题描述
有谁知道我可以用来实现与剪辑路径相同的结果以围绕 div 制作圆形形状的 CSS 属性?我的网站需要与最新版本的 IE 兼容,但我在 www.caniuse.com 上进行了检查,IE 11 不支持 clip-path。
我当前的代码可以在这个 codepen 中看到:https ://codepen.io/CodingGilbert/pen/BqwoGm?editors=1100
问题是,这段代码在 IE 中不起作用,我该如何解决这个问题?当然必须有另一个 CSS 属性做同样的事情。
.card {
width: 80%;
height: 16.5rem;
border-radius: 5px;
background-color: #fff;
text-align: center;
padding: 0 1.5rem;
margin:10rem auto;
}
.card__inner-wrapper {
height: 55%;
position: relative;
margin: 0 auto;
display: flex;
justify-content: center; }
.card__img {
height: 100%;
position: absolute;
bottom: 50%;
clip-path: circle(50% at 50% 50%);
background-color: #fff;
border: 0.8rem solid #fff; }
.card__text-content {
position: absolute;
top: 6rem; }
.card__heading {
font-size: 1.8rem;
font-weight: 500;
color: #5fc0c3;
margin-bottom: 1.5rem; }
解决方案
在这种情况下,border-radius: 50%;
on.card__img
会给你同样的结果,并且它兼容 IE9 及更高版本。
演示:
body {
background-color: gray;
}
.card {
width: 80%;
height: 16.5rem;
border-radius: 5px;
background-color: #fff;
text-align: center;
padding: 0 1.5rem;
margin: 10rem auto;
}
.card__inner-wrapper {
height: 55%;
position: relative;
margin: 0 auto;
display: flex;
justify-content: center;
}
.card__img {
height: 100%;
position: absolute;
bottom: 50%;
border-radius: 50%; /* instead of clip-path */
background-color: #fff;
border: 0.8rem solid #fff;
}
.card__text-content {
position: absolute;
top: 6rem;
}
.card__heading {
font-size: 1.8rem;
font-weight: 500;
color: #5fc0c3;
margin-bottom: 1.5rem;
}
<div class="card">
<div class="card__inner-wrapper">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Light_bulb_icon_red.svg/2000px-Light_bulb_icon_red.svg.png" alt="Bulb icon" class="card__img">
<div class="card__text-content">
<h4 class="card__heading">We help charities</h4>
<p>Share knowledge and working practice to make the best technology choices.</p>
</div>
</div>
</div>
推荐阅读
- javascript - ChartJS 为每列添加不同的行
- powerbi - 如何在 power bi 的 Total Cost Value 列中放置连字符
- java - 是否可以为Android手机和电视创建一个apk?
- swift - 'requestReview()' 在 iOS 14.0 中已弃用
- tesseract - 使用 Apache Tika 进行合理的 Tesseract OCR 设置……?
- flutter - 在 NestedScrollView 内的 tabView 中访问 NestedScrollController(以滚动到某个元素)
- ruby-on-rails - 使用 CombinePDF 将文本添加到现有 PDF 时出现编码问题
- node.js - 带有打字稿的猫鼬?
- php - 在 PHP 中从 SFTP 服务器打开 CSV 文件
- react-native - 当应用程序处于后台状态时如何暂停时钟