在我目前正在開發的移動網路應用程式中,我想使用帶有“波浪形”底部邊緣的標題欄。我這樣做的方法如下所示。
:root {
--lx-white: #fff;
--lx-fontPrimary: calc(12px ((100vh - 500px)/500)*4);
--lx-fontSecondary: calc(10px ((100vh - 500px)/500)*4);
--lx-Z0: 0;
--lx-Z1: 1000;
--lx-small-margin: 0.5rem;
--lx-std-margin: 1rem;
--lx-mid-margin: 1.5rem;
--lx-big-margin: 2rem;
--lx-small-pad: 0.5rem;
--lx-std-pad: 1rem;
--lx-big-pad: 2rem;
--lx-std-radius: 8px;
--lx-small-radius: 4px;
--lx-big-radius: 12px;
--lx-orange: #de6520;
--lx-light-orange: #e68a55;
--lx-white: white;
--lx-bg-white: #f2f4f3;
--lx-light-grey: #999999;
--lx-fontSize-minus1: 0.9rem;
--lx-fontSize-plus1: 1.1rem;
--lx-fontSize-plus2: 1.2rem;
--lx-fontSize-plus3: 1.3rem;
--lx-fontSize-plus5: 1.5rem;
--lx-fontFace-main: 'arial';
}
html,
body {
margin: 0;
padding: 0;
font-family: var(--lx-fontFace-main);
}
.fullScreen {
height: 100vh;
width: 100vw;
}
.scrollBox {
position: relative;
}
.scrollContainer {
position: absolute;
left: 0;
top: -100px;
right: 0;
bottom: 0;
padding: var(--lx-std-pad);
z-index: var(--lx-Z0);
}
.flexCentered {
display: flex;
align-items: center;
justify-content: center;
}
.btnBox {
background-color: var(--lx-bg-white);
padding-bottom: var(--lx-std-pad);
}
button {
border-style: none;
border-radius: var(--lx-std-radius);
background-color: var(--lx-orange);
padding: var(--lx-std-pad);
color: var(--lx-white);
}
.mainButton {
font-size: var(--lx-fontSize-plus1);
font-weight: bold;
}
.wideBtn {
min-width: 60vw !important;
}
#tosScreen {
display: grid;
position: relative;
grid-template-rows: 12vh 1fr 12vh;
}
#tosHeader {
z-index: var(--lx-Z1);
}
#tosH1 {
margin: 0;
padding: 0;
padding-left: var(--lx-std-pad);
font-size: var(--lx-fontSize-plus3);
text-align: left;
background-color: var(--lx-light-orange);
color: var(--lx-white);
padding-top: 2rem;
padding-bottom: 1rem;
}
#tosFooter {
background-color: rgba(255, 255, 255, 0.8);
z-index: var(--lx-Z1);
padding-top: var(--lx-big-pad);
}
<div class='fullScreen' id='tosScreen'>
<header id='tosHeader'>
<h1 id='tosH1'>Terms of Service</h1>
<svg viewBox="0 0 375 56" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path style="fill:#e68a55" d="M-.171-.059h374.734v36.17H-.171z" transform="matrix(1.00071 0 0 1 .172 .059)"/><path d="M375 148.52v8.36c-33.3 9.15-90 18.28-165.06 6.51-83.31-13.08-164.87-3.78-209.94 3.87v-54.17c.5 6.13.78 9.61.78 9.61s65 38.28 174.47 18.69c84.12-15.06 166.21-.45 199.75 7.13Z" style="fill:#de6520;fill-rule:nonzero" transform="translate(0 -113.031)"/></svg>
</header>
<div class='scrollBox'>
<div class='scrollContainer' id='termsScroller'>
</div>
</div>
<footer id='tosFooter'>
<div class='btnBox flexCentered'>
<button id='btnContinue' class='wideBtn mainButton'>Continue</button>
</div>
</footer>
</div>
當我在 Chrome 和 Opera 中查看此內容并切換顯示以模擬移動螢屏時,我看到一條微弱的白線將標題與其下方的 SVG 分隔開。這在 Edge 上似乎不會發生。我懶得在 Firefox 上測驗這個 - 反正與我的專案無關。
這是什么原因造成的?

在上面的螢屏截圖中,我試圖突出顯示藍色虛線矩形中線的位置
uj5u.com熱心網友回復:
我不確定這是否是您所指的空間 - 如果是,它是由 svg 是行內元素引起的。嘗試將其更改為阻止 - 空間應該消失了
svg {
display: block;
}

如果與形狀渲染相關 - 嘗試添加shape-rendering="crispEdges"到 svg 中的第一個路徑
<path
style="fill:#e68a55"
d="M-.171-.059h374.734v36.17H-.171z"
transform="matrix(1.00071 0 0 1 .172 .059)"
shape-rendering="crispEdges"
/>
編輯- 我使用SVGOMG進行了一些優化以簡化形狀 - 也許這也行
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 375 56">
<path fill="#E68A55" d="M0 0h375v36.2H0z"/>
<path fill="#DE6520" d="M375 35.5v8.3c-33.3 9.2-90 18.3-165 6.6-83.4-13.1-165-3.8-210 3.8V9.1l.8.6s65 38.2 174.4 18.7c84.2-15.1 166.3-.5 199.8 7Z"/>
</svg>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/366431.html
上一篇:我可以以某種方式參考比我需要參考的類晚宣告的Python類而不改變它們的順序嗎?
下一篇:懸停效果的SVG顏色變化
