【发布时间】:2021-10-17 00:14:08
【问题描述】:
我正在尝试找到一个 SVG,使其看起来像这样:
我想通过::before 或::after 伪元素来做到这一点。但我不能,因为 SVG 太大,而且它的第一个位置远离父元素的边界。
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>A modern <span>publishing platform</span> </h1>
<p>Grow your audience and build your online brand</p>
<div class="buttons">
<button class="btn ">Start for Free</button>
<button class="btn border ">Learn More</button>
</div>
</header>
</body>
</html>
*{
box-sizing: border-box;
}
html{
font-size: 10px;
}
body{
margin: 0;
padding: 0;
font-family: Poppins;
position: relative;
}
header{
width: 100%;
padding:2rem;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
color: white;
border-bottom-left-radius: 12rem;
position: relative;
z-index: -1;
background-image: linear-gradient(to right,
hsl(13, 100%, 72%),
hsl(353, 100%, 62%));
h1{
margin-top: 10rem;
width: 100%;
font-size: 2.7rem;
span{
display:block;
}
}
p{
font-size: 1.7rem;
font-weight: 100;
}
.buttons{
display: flex;
align-items: center;
justify-content: flex-end;
.btn{
padding: 1rem 2rem;
background-color: white;
border-radius: 3rem;
border: none;
margin: 0px 1rem;
font-style: 400;
font-family: Poppins;
border: .1rem solid white;
}
.border{
background-color: transparent;
color: white;
}
margin-bottom: 10rem;
}
}
header::before{
content: url(images/bg-pattern-intro.svg);
position: absolute;
transform: scale(.1);
}
谁能告诉我该怎么做?为什么 .svg 不首先将自己定位在其父级的边界附近?
【问题讨论】:
标签: html css svg pseudo-element