在我正在編寫的網站中,我使用svg路徑來繪制網頁頂部和底部的邊界。當我使用大屏幕時,一切似乎都很好,但如果我使用移動設備,曲線會向上(或向下)彎曲,覆蓋了部分內的文本。知道我該怎么解決這個問題嗎?我想保持這種設計也適用于移動設備。為了更好地理解我的問題,我在這里放了一些圖片
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
*::before,
*::after {
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
body {
font-family: "Rubik", sans-serif;
color: #444;
padding: 0 /* 1rem */;
}
/* -------- NAV2 ----------- */
.header {
width: 100%;
height: 8rem;
padding: 0.6rem;
border-top: 0.5rem solid #fff;
background-color: #f2a900;
display: flex;
/* flex-direction: row; */
justify-content: space-between;
align-items: center;
}
.header2 {
width: 100%;
height: 8rem;
padding: 0.6rem;
border-top: 0.5rem solid #f2a900;
background-color: rgba(255, 255, 255, 0.9);
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
top: 0;
bottom: 0;
z-index: 999;
box-shadow: 0 1.2rem 3.2rem rgba(0, 0, 0, 0.03);
}
.logo2 {
height: 5.2rem;
}
nav ul {
height: 100%;
}
.header ul,
.header2 ul {
list-style: none;
display: flex;
align-items: center;
justify-content: space-around;
}
.header ul li,
.header2 ul li {
font-size: 1.6rem;
padding-right: 1.8rem;
list-style: none;
text-decoration: none;
}
/* -------- Header primary ----------- */
.main-nav-link2 {
text-decoration: none;
}
.main-nav-link2:link,
.main-nav-link2:visited {
text-decoration: none;
color: #fff;
font-weight: 500;
font-size: 1.8rem;
transition: all 0.3s;
}
.main-nav-link2:hover,
.main-nav-link2:active {
color: #fceecc;
}
.main-nav-link2.nav-cta2:link,
.main-nav-link2.nav-cta2:visited {
padding: 1.2rem;
border-radius: 0.5rem;
color: #fff;
background-color: #da9800;
}
.main-nav-link2.nav-cta2:hover,
.main-nav-link2.nav-cta2:active {
background-color: #c28700;
color: #fceecc;
}
#hamburger-icon2 {
margin: auto 3rem auto 0;
display: none;
cursor: pointer;
}
#hamburger-icon2 div {
width: 35px;
height: 3px;
background-color: #fff;
margin: 6px 0;
transition: 0.4s;
}
/* ---------- Header Secondary ----------- */
.main-nav-link {
text-decoration: none;
}
.main-nav-link:link,
.main-nav-link:visited {
text-decoration: none;
color: #f2a900;
font-weight: 500;
font-size: 1.8rem;
transition: all 0.3s;
}
.main-nav-link:hover,
.main-nav-link:active {
color: #c28700;
}
.main-nav-link.nav-cta:link,
.main-nav-link.nav-cta:visited {
padding: 1.2rem;
border-radius: 0.5rem;
color: #fff;
background-color: #f2a900;
}
.main-nav-link.nav-cta:hover,
.main-nav-link.nav-cta:active {
background-color: #c28700;
color: #fceecc;
}
#hamburger-icon {
margin: auto 3rem auto 0;
display: none;
cursor: pointer;
}
#hamburger-icon div {
width: 35px;
height: 3px;
background-color: #f2a900;
margin: 6px 0;
transition: 0.4s;
}
.open .bar1 {
-webkit-transform: rotate(-45deg) translate(-6px, 6px);
transform: rotate(-45deg) translate(-6px, 6px);
}
.open .bar2 {
opacity: 0;
}
.open .bar3 {
-webkit-transform: rotate(45deg) translate(-6px, -8px);
transform: rotate(45deg) translate(-6px, -8px);
}
.open .mobile-menu {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
background-color: rgba(255, 255, 255, 0.9);
}
.mobile-menu {
display: none;
position: absolute;
top: 7.5rem;
left: 0;
height: calc(100vh - 50px);
width: 100%;
}
.mobile-menu li {
margin-bottom: 10px;
padding-bottom: 2rem;
}
/* ----- start main header dropdwon menu ------- */
.open .mobile-menu2 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
background-color: hsla(42, 100%, 47%, 0.8);
}
.mobile-menu2 {
display: none;
position: absolute;
top: 7.5rem;
left: 0;
height: calc(100vh - 50px);
width: 100%;
z-index: 999;
}
.mobile-menu2 li {
margin-bottom: 10px;
padding-bottom: 2rem;
}
/* ------ end main header dropddown menu --------*/
.hide {
opacity: 0;
left: -100%;
}
.show {
opacity: 1;
left: 0;
}
h1 {
display: inline-block;
animation-name: moveInLeft;
animation-duration: 2s;
}
.price {
font-size: 24px;
font-weight: bold;
}
.hero {
display: flex;
flex-direction: column;
place-items: center;
padding-top: 9.6rem;
position: relative;
height: 85vh;
background-image: linear-gradient(
0deg,
rgba(242, 169, 0, 0.5),
rgba(242, 169, 0, 0.5)
),
url(../images/moscow-city.jpg);
background-size: cover;
background-position: center;
overflow: hidden;
}
.value1 h2 {
font-weight: bold;
}
.hero-txt {
text-align: center;
margin: 1.5rem auto;
font-size: 1.6rem;
}
.hero-txt2 {
margin-top: 1rem;
font-size: 1.9rem;
}
.hero-btn {
padding: 1.6rem;
background-color: #f2a900;
border-radius: 1.8rem;
display: inline-block;
}
.hero-btn:hover {
padding: 1.5rem;
color: #fceecc;
}
.hero-btn-container a,
a:visited {
color: #fff;
text-decoration: none;
font-size: 1.8rem;
}
.svg-1 {
position: absolute;
bottom: 0;
}
.svg-2 {
bottom: 0;
position: absolute;
}
.hero h1 {
font-size: 5rem;
}
.lang {
margin: 2rem auto 1.6rem auto;
}
.fi {
font-size: 3rem;
border-radius: 50%;
cursor: pointer;
text-decoration: none;
display: inline-block;
opacity: 0.5;
transition: all 0.4s;
}
.fi:hover {
transform: translateY(-2px);
opacity: 0.8;
}
<div class="header" id="header">
<div id="brand">
<a href="#">
<img class="logo2" alt="bitcoin atm moscow logo" src="images/logo.png" />
</a>
</div>
<nav>
<ul>
<li><a class="main-nav-link2" href="#about">About us</a></li>
<li><a class="main-nav-link2" href="#benefit">How to buy</a></li>
<li>
<a class="main-nav-link2 nav-cta2" href="#map">Where we are</a>
</li>
<li><a class="main-nav-link2" href="#why-box">Why us</a></li>
<li><a class="main-nav-link2" href="#footer">Contacts</a></li>
</ul>
</nav>
<div id="hamburger-icon2" onclick="toggleMobileMenu(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<ul class="mobile-menu2">
<li><a class="main-nav-link2" href="#about">About us</a></li>
<li><a class="main-nav-link2" href="#benefit">How to buy</a></li>
<li>
<a class="main-nav-link2 nav-cta2" href="#map">Where we are</a>
</li>
<li><a class="main-nav-link2" href="#why-box">Why us</a></li>
<li><a class="main-nav-link2" href="#footer">Contacts</a></li>
</ul>
</div>
</div>
<div class="header2 hide" id="header2">
<div id="brand">
<a href="#">
<img class="logo2" alt="bitcoin atm moscow logo" src="images/logo2.png" />
</a>
</div>
<nav>
<ul>
<li><a class="main-nav-link" href="#header">Home</a></li>
<li><a class="main-nav-link" href="#about">About us</a></li>
<li><a class="main-nav-link" href="#benefit">How to buy</a></li>
<li>
<a class="main-nav-link nav-cta" href="#map">Where we are</a>
</li>
<li><a class="main-nav-link" href="#why-box">Why us</a></li>
<li><a class="main-nav-link" href="#footer">Contacts</a></li>
</ul>
</nav>
<div id="hamburger-icon" onclick="toggleMobileMenu(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<ul class="mobile-menu">
<li><a class="main-nav-link" href="#header">Home</a></li>
<li><a class="main-nav-link" href="#about">About us</a></li>
<li><a class="main-nav-link" href="#benefit">How to buy</a></li>
<li>
<a class="main-nav-link nav-cta" href="#map">Where we are</a>
</li>
<li><a class="main-nav-link" href="#why-box">Why us</a></li>
<li><a class="main-nav-link" href="#footer">Contacts</a></li>
</ul>
</div>
</div>
<div class="hero">
<div class="lang">
<a href="index.php" title="русский" class="fi fi-ru fis"> </a>
<a href="index_en.php" title="english" class="fi fi-gb fis"></a>
<a href="index_it.php" title="italiano" class="fi fi-it fis"></a>
</div>
<div class="hero-txt"><h2>Only 21 millions of Bitcoins will be created and we are more than 8 billions in this world:<br></h2>
<div class="hero-txt2"> <h2>what are you waiting to get yours?</div></h2>
</div>
<div class="hero-btn-container">
<a href="#map-box" class="hero-btn">Buy Bitcoin</a>
</div>
<svg
class="svg-1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 1424 224"
>
<path
fill="#f2a900"
fill-opacity="1"
d="M0,32L120,58.7C240,85,480,139,720,138.7C960,139,1200,85,1320,58.7L1440,32L1440,320L1320,320C1200,320,960,320,720,320C480,320,240,320,120,320L0,320Z"
></path>
</svg>
<svg
class="svg-2"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 1440 220"
>
<path
fill="#fff"
fill-opacity="1"
d="M0,32L120,58.7C240,85,480,139,720,138.7C960,139,1200,85,1320,58.7L1440,32L1440,320L1320,320C1200,320,960,320,720,320C480,320,240,320,120,320L0,320Z"
></path>
</svg>
<div class="cta"></div>
</div>
</header>
你提到你的網站移動工作正常,并使用SVG的方式,你已經彎曲的網頁頂部和底部的邊緣。在大屏幕上,一切似乎都很好,但在移動設備上,彎曲部分太高或太低,占用了分區內的文本 請務必使用標簽來正確顯示移動設備。正確的視圖設置有助于設備檢測屏幕寬度并正確縮放內容。例如,您可以使用以下標簽: