如何使用 css 和 html 让黑色单词适合红色单词,就像我的设计中一样

发布于 2025-01-10 09:57:04 字数 1322 浏览 0 评论 0原文

在此处输入代码与问题一起使用的参考照片 在此处输入代码我的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 herereference photo to go along with question
enter code heremy css
enter code heremy 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光礼记 2025-01-17 09:57:04

由于元素 .loveh1 的子元素,因此您可以在 h1.love 和相对位置代码>.然后设置 topleft 位置以相对于其父元素定位。

将 h2 元素添加到标题中,以便可以在标题上使用 flex,并将 flex-direction 设置为 column。在 h1 元素上重复弯曲和列弯曲方向,以便子元素堆叠。将第一个部分包裹在一个跨度中并给它一个类,这样它就可以向左移动 1rem。使用草书爱情类来设计爱情元素。然后将love的第一个字母包裹在span标签中,并给它一个类,以便可以使用font-size放大它。

h2 元素样式并添加 flexjustify-content: center,然后进一步调整边距。添加填充以容纳 love 字符。

* {
  margin: 0;
}

.wrapper {
  max-width: 1080px;
  margin: 0 auto;
}

.title {
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  color: black;
  font-family: fino;
  display: flex;
  /* flex allows ease of centering elements */
  flex-direction: column;
  /* set flex direction as column */
  align-items: end;
  /* center items */
  position: relative;
  /* set position to relative */
  padding-left: 3.8rem;
  /* this makes space for the love characters */
  letter-spacing: -1px;
}

h2 {
  /* add flex to h2 element for centering */
  display: flex;
  justify-content: center;
  letter-spacing: -1px;
  font-size: .9rem;
  margin-left: 2rem;
  margin-top: -.5rem;
}

.big {
  font-size: 5rem;
}

.first {
  margin-right: 1rem;
}

.love {
  /* style font to similar of the logo */
  font-family: adorn-smooth-pomander, sans-serif;
  font-weight: 400;
  font-style: normal;
  color: red;
  position: absolute;
  /* position absolute to remove element from page flow */
  top: -.7rem;
  /* top set to the top position of next element set to position relative */
  left: 0;
  /* left set to the left position of next element set to position relative */
  font-size: 4rem;
}

.cursive {
  /* helper class to style love */
  font-family: 'Dancing Script', cursive;
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap" rel="stylesheet">
<div class=title>
  <h1>
    <span class="first">PAGES FROM A </span>
    <span class="love cursive">
      <span class="big">L</span>ove
    </span> 
    MANIFESTO
  </h1>
  <h2>
    Devised by Dom Torrez | Department of Theatre Art
  </h2>
</div>

Since the element .love is a child of the h1 you can position the .love absolutely and position relative on the h1. 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 to column. 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 using font-size.

h2 element style and add flex and justify-content: center, then further adjust with margin. Add padding to accommodate the love characters.

* {
  margin: 0;
}

.wrapper {
  max-width: 1080px;
  margin: 0 auto;
}

.title {
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  color: black;
  font-family: fino;
  display: flex;
  /* flex allows ease of centering elements */
  flex-direction: column;
  /* set flex direction as column */
  align-items: end;
  /* center items */
  position: relative;
  /* set position to relative */
  padding-left: 3.8rem;
  /* this makes space for the love characters */
  letter-spacing: -1px;
}

h2 {
  /* add flex to h2 element for centering */
  display: flex;
  justify-content: center;
  letter-spacing: -1px;
  font-size: .9rem;
  margin-left: 2rem;
  margin-top: -.5rem;
}

.big {
  font-size: 5rem;
}

.first {
  margin-right: 1rem;
}

.love {
  /* style font to similar of the logo */
  font-family: adorn-smooth-pomander, sans-serif;
  font-weight: 400;
  font-style: normal;
  color: red;
  position: absolute;
  /* position absolute to remove element from page flow */
  top: -.7rem;
  /* top set to the top position of next element set to position relative */
  left: 0;
  /* left set to the left position of next element set to position relative */
  font-size: 4rem;
}

.cursive {
  /* helper class to style love */
  font-family: 'Dancing Script', cursive;
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap" rel="stylesheet">
<div class=title>
  <h1>
    <span class="first">PAGES FROM A </span>
    <span class="love cursive">
      <span class="big">L</span>ove
    </span> 
    MANIFESTO
  </h1>
  <h2>
    Devised by Dom Torrez | Department of Theatre Art
  </h2>
</div>

别忘他 2025-01-17 09:57:04

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

* {
  margin: 0;
}

.wrapper {
  max-width: 1080px;
  margin: 0 auto;
}

h1 {
  color: black;
  font-family: fino;
  font-size: 2em;
  line-height: 1;
  text-transform: uppercase;

}

h2 {
  display: inline-block;
  font-size: 1em;
  margin-left: -50px;
}

.pages {
  margin-left: -40px;
}

.love {
  font-family: adorn-smooth-pomander, sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 3em;
  text-transform: initial;
  color: red;
  float: left;
}

.ove {
  display: inline-block;
  font-size: .45em;
  line-height: 0.5;
  transform: translateY(-20px);
}
 <div class=title>
   <h1>
     <span class="pages">Pages from a</span> <span class="love">L<span class="ove">ove</span></span><br> Manifesto
   </h1>
 </div>


 <h2>
   Devised by Dom Torrez | Department of Theatre Art
 </h2>

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 margins or transfrom: translate. But again, i would advise to not do this, because you would only work with "Magic Numbers" and it's easy to break.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文