将跨距放入跨度内联(Putting a span inside a span inline)

编程入门 行业动态 更新时间:2024-10-20 01:36:21
跨距放入跨度内联(Putting a span inside a span inline)

我想显示一个大字体大的跨度和内联,我想添加分为两行的字幕(标题|一个)(标题|两个)等。

我可以通过使用字幕的手动页边距和绝对定位来实现这一点,但HTML和CSS非常快速地变得非常混乱。 也许我应该使用CSS网格?

我已经附加了我希望使用的html体结构和我将使用的.content css。 以及我希望实现的形象。

<div class="content"> <h1> <span class="name">Firstname Las</span> <span class="title">Title 1</span> <span class="title">Title</span> </h1> </div> .content { position: absolute; top: 50%; left: 50%; margin: 0 auto; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }

I want to display a large span with a large font size and within that inline, I want to add subtitles that are divided into two rows (Title | One) (Title | Two) etc..

I can achieve this somewhat by using manual margining and absolute positioning of the subtitles, but the HTML and CSS gets very messy very quickly. Perhaps I should use CSS grid?

I have attached the html body structure I hope to be using and .content css that I will be using. And the image of what I hope to achieve.

<div class="content"> <h1> <span class="name">Firstname Las</span> <span class="title">Title 1</span> <span class="title">Title</span> </h1> </div> .content { position: absolute; top: 50%; left: 50%; margin: 0 auto; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }

最满意答案

您可以尝试以下解决方案:

.content {
    position: absolute;
    top: 50%;
    left: 50%;
    margin: 0 auto;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}
.fname{
  display:block
}
.title{      
  font-size: 11px;
    width: 20px !important;
    white-space: normal;
    display: inline-block;

} 
  
<div class="content">
  <h1>
    <span class="fname">Firstname</span>
    <span class="lname">Las</span>
    <span class="title">Title one</span>
    <span class="title">Title</span>            
  </h1>
</div> 
  
 

You can try below solution :

.content {
    position: absolute;
    top: 50%;
    left: 50%;
    margin: 0 auto;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}
.fname{
  display:block
}
.title{      
  font-size: 11px;
    width: 20px !important;
    white-space: normal;
    display: inline-block;

} 
  
<div class="content">
  <h1>
    <span class="fname">Firstname</span>
    <span class="lname">Las</span>
    <span class="title">Title one</span>
    <span class="title">Title</span>            
  </h1>
</div> 
  
 

更多推荐

本文发布于:2023-04-28 05:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1330306.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:跨距   内联   跨度   放入   inline

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!