سؤال

لديّ عنصر ومن الممكن أن يكون أطول من سطر واحد ، لذلك يجب أن أقوم بتعيين خط فرز> 1 وإلا فإنه يبدو كريبيًا. ولكن إذا فعلت ذلك ، فإن الخطوط أعلى من النص ، ويتمحور النص. لذلك لا يتطابق مع القمة. كيف يمكنني تغيير موضع النص إلى أعلى الخط ، أم أن هناك طريقة أخرى للحصول على بعض المساحة بين سطرين؟

هل كانت مفيدة؟

المحلول

Line height by definition centers the font-size within the given line height. If you have a 12px font and a 16px line-height, the text will be centered within the 16px, leaving 2px on both the top and the bottom.

One solution to push this text up while maintaining the line height is to add a negative margin to the element and push it up negatively:

float: left;
margin-top: -2px;

نصائح أخرى

Try this:

<style type="text/css">
.spacer
{
 line-height:1px;
}

.spacer:after
{
 content:".";
 visibility:invisible;
 line-height:1px;
}
</style>

You can increase the line height in the above CSS code there and use it like this:

your line one
<p class="spacer"></p>
your line two
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top