[英]Remove space between span-s
I want to remove this space to make <span>
-s closer, but there is no any margin or padding that could add more space between them.我想删除此空间以使
<span>
-s 更接近,但没有任何边距或填充可以在它们之间增加更多空间。
<!-- HTML -->
<div class="service-container" id="logo-title-service-container">
<span class="logo-text" id="logo-title">company name</span><br>
<span class="logo-text" id="logo-subtitle">This is a subtitle</span>
</div>
Sass Sass
// Sass
#logo-title-service-container
text-align: left
padding-left: 10px
#logo-title
font-size: 18px
#logo-subtitle
padding-top: -5px
font-size: 12px
How can I remove the space between them?我怎样才能删除它们之间的空间?
You should remove the 'br' element first.您应该先删除“br”元素。
then make the display of title and subtitle block or as i did here make the parent display flex and flex-direction to column to make it work.然后显示标题和副标题块,或者像我在这里所做的那样,使父显示 flex 和 flex-direction 到列以使其工作。
#logo-service-container { width: 100%; text-align: center; padding-top: 15px; display: flex; align-items: center; justify-content: center; } #logo-main { width: 26px; height: 26px; } #logo-title-service-container { display: flex; flex-direction: column; text-align: left; padding-left: 10px; } #logo-title { font-size: 18px; } #logo-subtitle { font-size: 12px; }
<div class="sidebar" id="left-sidebar"> <div class="service-container" id="logo-service-container"> <img id="logo-main" src="resources/images/icons/logo.svg" alt="logo"> <div class="service-container" id="logo-title-service-container"> <span class="logo-text" id="logo-title">company name</span> <span class="logo-text" id="logo-subtitle">This is a subtitle</span> </div> </div> </div>
You should try to avoid <br>
你应该尽量避免
<br>
replace the span with div用 div 替换 span
<div class="sidebar" id="left-sidebar">
<div class="service-container" id="logo-service-container">
<img id="logo-main" src="resources/images/icons/logo.svg" alt="logo">
<div class="service-container" id="logo-title-service-container">
<div class="logo-text" id="logo-title">company name</div>
<div class="logo-text" id="logo-subtitle">This is a subtitle</div>
</div>
</div>
</div>
SASS: SASS:
#logo-service-container
width: 100%
text-align: center
padding-top: 15px
display: flex
align-items: center
justify-content: center
#logo-main
$size: 26px
width: $size
height: $size
#logo-title-service-container
text-align: left
padding-left: 10px
#logo-title
font-size: 18px
#logo-subtitle
padding-top: -5px
font-size: 12px
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.