如何使用 css 和 html 让黑色单词适合红色单词,就像我的设计中一样
在此处输入代码
与问题一起使用的参考照片 在此处输入代码
我的CSS 在此处输入代码
我的 hmtl
我想也许我会将“Pages from a”、“Love”和“Manifesto”分成3个单独的块,但我不知道如何让“Pages from a”和“Manifesto”适应“love”这个词,就像我设计的那样。如果没有必要,我真的不想使用它的图像,我宁愿学习正确的方法。
我是编码新手,我尝试环顾四周并自己解决这个问题,但说实话,我什至不知道如何寻找解决方案,或者从哪里开始解决这个问题,因为我只是对这个主题了解不够,不知道我所看到的是否有帮助。
请帮忙!
*{
margin: 0;
border: 1px solid black;
}
.wrapper {
max-width: 1080px;
margin: 0 auto;
}
h1{
color: black;
font-family: fino;
text-align: center;
}
.love{
font-family: adorn-smooth-pomander, sans-serif;
font-weight: 400;
font-style: normal;
color: red;
}
<div class=title>
<h1>
Pages from a <span class="love">Love</span>
Manifesto
</h1>
</div>
<h2>
Devised by Dom Torrez | Department of Theatre Art
</h2>
enter code here
reference photo to go along with questionenter code here
my cssenter code here
my hmtl
I was thinking maybe I'd have to break "Pages from a" "Love" and "Manifesto" into 3 separate chunks, but I don't know how to get "Pages from a" and "Manifesto" to fit around the word love like how I've designed it. I really don't want to use an image of it if I don't have to, I'd rather learn the proper way.
I'm new to coding and I tried to look around and figure this out on my own, but if I'm being honest I don't even know how to search for a solution or where to even start to go about this because I just don't know enough about the topic to know if what I'm seeing will even help.
Please help!
*{
margin: 0;
border: 1px solid black;
}
.wrapper {
max-width: 1080px;
margin: 0 auto;
}
h1{
color: black;
font-family: fino;
text-align: center;
}
.love{
font-family: adorn-smooth-pomander, sans-serif;
font-weight: 400;
font-style: normal;
color: red;
}
<div class=title>
<h1>
Pages from a <span class="love">Love</span>
Manifesto
</h1>
</div>
<h2>
Devised by Dom Torrez | Department of Theatre Art
</h2>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于元素
.love
是h1
的子元素,因此您可以在h1.love
和相对位置代码>.然后设置 top 和 left 位置以相对于其父元素定位。将 h2 元素添加到标题中,以便可以在标题上使用 flex,并将
flex-direction
设置为column
。在 h1 元素上重复弯曲和列弯曲方向,以便子元素堆叠。将第一个部分包裹在一个跨度中并给它一个类,这样它就可以向左移动 1rem。使用草书和爱情类来设计爱情元素。然后将love的第一个字母包裹在span标签中,并给它一个类,以便可以使用font-size
放大它。h2
元素样式并添加 flex 和 justify-content: center,然后进一步调整边距。添加填充以容纳 love 字符。Since the element
.love
is a child of theh1
you can position the.love
absolutely and position relative on theh1
. Then set the top and left position to position it relative to its parent element.Add the h2 element to the title so flex can be used on title with
flex-direction
set tocolumn
. Repeat flex and column flex direction on h1 element so the children will stack. Wrap the first section in a span and give it a class so it can be nudged to the left 1rem. Style love element with cursive and love class. Then wrap the first letter of love in a span tag and give it a class so it can be enlarged usingfont-size
.h2
element style and add flex and justify-content: center, then further adjust with margin. Add padding to accommodate the love characters.continue
First of all, i don't think you should do this in pure HTML/CSS at all.
The proper way to do it is probably using an
svg
or actually an Image.But if you insist on doing it with CSS, here you go
I think the
float
was your missing puzzle piece to wrap the rest around the "Love".Now you have to change the position of the rest of the text with either negative
margin
s ortransfrom: translate
. But again, i would advise to not do this, because you would only work with "Magic Numbers" and it's easy to break.