gpt4 book ai didi

html - body 左侧和右侧的垂直 Zig Zag 边框

转载 作者:行者123 更新时间:2023-11-28 16:58:54 25 4
gpt4 key购买 nike

我正在尝试制作一些 CSS 代码,以便在我的 BODY 标签的左侧和右侧有垂直的锯齿线。

我希望它看起来像一张票……在页面的左右两边从上到下是这样的:https://roalddahl.fandom.com/wiki/Golden_Ticket?file=Golden_Ticket.png

我发现这个问题需要左边的锯齿形,但是当我在 BODY 上使用 on 时它对我来说不能正常工作:zigzag border in css left side

body {
background-color: #c5ac5a;
background: linear-gradient(-137deg, #c5ac5a 6px, transparent 0) 0 5px, linear-gradient(320deg, #c5ac5a 5px, #fff 0) 0 5px;
background-position: left;
background-repeat: repeat-y;
background-size:10px 10px;
}
<body>
<h1>The Title</h1>
</body>

编辑:我希望整个背景为#c5ac5a 和两侧的垂直锯齿形。

最佳答案

使用 :before:after 来实现您的目标。 (我还更改了列以使用 flex,但这对于手头的问题来说不是必需的)。请参阅下面提供的代码段:

body {
background: white;
}

.ticket {
background-color: #c5ac5a;
position: relative;
padding: 10px;
}

.ticket:before,
.ticket:after {
top: 0;
left: -10px;
content: '';
width: 10px;
height: 100%;
position: absolute;
background-color: #c5ac5a;
background: linear-gradient(-137deg, #c5ac5a 6px, transparent 0) 0 5px, linear-gradient(320deg, #c5ac5a 5px, transparent 0) 0 5px;
background-position: left;
background-repeat: repeat-y;
background-size:10px 10px;
}

.ticket:after {
left: auto;
right: -10px;
top: 0;
transform: scaleX(-1);
}

.hr {
border-bottom: 2px solid black;
}

h1 {
text-align: center;
font-family: Times, serif;
font-size:40px;
}

.column {
text-align:center;
flex: 1 1 auto;
padding: 10px 0;
}

.row {
display: flex;
}

.ticket__footer {
font-size: 12px;
text-align: center;
padding-top: 10px;
}

.bold {
font-weight:bold;
}
<div class="ticket">
<div class="hr">
</div>
<div class="title">
<h1>
GOLDEN TICKET
</h1>
</div>

<div class="hr">
</div>

<div class="row">
<div class="column">
<span class="small">DATE</span></br>
<span class="bold">FEB. 1</span>
</div>
<div class="column">
<span class="small">TIME</span></br>
<span class="bold">10 A.M (SHARP)</span>
</div>
<div class="column">
<span class="small">PLACE</span></br>
<span class="bold">RIGHT HERE</span>
</div>
</div>

<div class="hr">
</div>

<div class="ticket__footer">
THIS GOLDEN TICKET ENSURES ADMITTANCE
</div>
</div>

关于html - body 左侧和右侧的垂直 Zig Zag 边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54653283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com