框阴影在 safari 上被父 div 截断
Posted
技术标签:
【中文标题】框阴影在 safari 上被父 div 截断【英文标题】:Box shadow gets cutoff by parent div on safari 【发布时间】:2022-01-20 15:26:12 【问题描述】:我在 safari 上遇到了这个盒子阴影的问题,它被标签截断并且不会超出它。
注意:这个问题只出现在safari上,其他浏览器都没有问题。
旁注我已经尝试使用 position:relative 和 z-index 和 overflow:visible 在所有父元素上,没有任何改变。
附言我不能使用填充,因为它会破坏布局。
<html>
<head>
</head>
<body>
<div class="icons">
<a href="https://www.linkedin.com/in/mohamed-aly-a3a781213/" class="socials" rel="noopener noreferrer" target="_blank" aria-label="linkedin">
<svg class="smalliconsquare" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/>
<defs>
<radialGradient id="Solid">
<stop offset="100%" stop-color="#6c6f7c"/>
</radialGradient>
<radialGradient id="RadialGradient1" cx="0.5" cy="0.5" r="0.4" fx="0.75" fy="0.75"
spreadMethod="reflect">
<stop offset="30%" stop-color="#b75aba"/>
<stop offset="100%" stop-color="#42c0ff"/>
</radialGradient>
</defs>
</svg>
</a>
<div class="emptyspace"></div>
<a href="https://github.com/Metwesh" class="socials" rel="noopener noreferrer" target="_blank" aria-label="github">
<svg class="smalliconcircle" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
<radialGradient id="RadialGradient2" cx="0.5" cy="0.5" r="0.4" fx="0.75" fy="0.75"
spreadMethod="reflect">
<stop offset="30%" stop-color="#b75aba"/>
<stop offset="100%" stop-color="#42c0ff"/>
</radialGradient>
</svg>
</a>
</div>
</body>
</html>
SCSS
.contentfoot
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 40px 40px;
background-color: $black;
height: auto;
overflow: visible;
overflow-wrap: unset;
@include breakpoint-down(medium)
padding: 20px 0;
.icons
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 0px 40px;
height: auto;
overflow: visible;
@include breakpoint-down(small)
padding: 10px 20px;
.socials
height: auto;
overflow: visible;
.smalliconsquare
width: 60px;
height: 60px;
border-radius: 13px;
fill:url(#Solid);
overflow: visible;
-webkit-transition: -webkit-box-shadow 150ms ease-in-out;
transition: -webkit-box-shadow 150ms ease-in-out;
-o-transition: all 150ms ease-in-out;
transition: all 150ms ease-in-out;
transition: all 150ms ease-in-out, -webkit-box-shadow 150ms ease-in-out;
@include breakpoint-down(small)
width: 50px;
height: 50px;
@include breakpoint-down(xsmall)
width: 45px;
height: 45px;
.emptyspace
height: 20px;
overflow: visible;
@include breakpoint-down(medium)
display: none;
.socials:last-child
border-radius: 70px;
.smalliconcircle
width: 60px;
height: 60px;
border-radius: 70px;
fill:url(#Solid);
overflow: visible;
-webkit-transition: -webkit-box-shadow 150ms ease-in-out;
transition: -webkit-box-shadow 150ms ease-in-out;
-o-transition: all 150ms ease-in-out;
transition: all 150ms ease-in-out;
transition: all 150ms ease-in-out, -webkit-box-shadow 150ms ease-in-out;
@include breakpoint-down(small)
width: 50px;
height: 50px;
@include breakpoint-down(xsmall)
width: 45px;
height: 45px;
a.socials:first-child:hover
.smalliconsquare
fill:url(#RadialGradient1);
-o-box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
-moz-box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
-webkit-box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
a.socials:last-child:hover
.smalliconcircle
fill:url(#RadialGradient1);
-o-box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
-moz-box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
-webkit-box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
box-shadow: 0 0 5px $black, 0 0 10px $purplish, 0 0 15px $blueish, 0 0 20px $cyan, 0 0 25px $lightpink;
【问题讨论】:
【参考方案1】:我通过将 box-shadow 放在父标签上并根据具有适当边框半径的 svg 调整其大小来修复它
【讨论】:
您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。以上是关于框阴影在 safari 上被父 div 截断的主要内容,如果未能解决你的问题,请参考以下文章
CSS Safari CSS3 Fun - 目标+边框半径+框阴影
iOS 7 上的 Safari Mobile 上未显示框阴影(横向)