Mini Program's text component, how to remove the default upper and inner margins?

Mini Program text component, there will be a default similar to the upper margin, but can not be dealt with with padding, this is Mini Program based on what consideration to increase this margin, is there any way to remove it?

clipboard.png

clipboard.png

Mar.03,2021

because you cannot wrap a line,
< text >
{{item.title}}
< / text >
, the blank area appears.
has to write in this way < text > {{item.title}} < / text >


. At first I wrote < view > {item.title}} < / view > and found the text on the left on the real machine after the line break. The text on the left side of the real machine is aligned, but in your case, there is a blank on it, it seems that padding-top, can not be removed. Later, I wrote < view > < / view > < text > {{item.title}} < / text >, two by one, damn it, magic, the two problems were solved together, text alignment, and the blanks above were removed


I also encountered the same problem. Come to think of it, the picture will also occupy a few pixels at the top in web development, because it is an inline element, so you only need to set the image to display:block (block-level element). The same should be used in Mini Program's < text style='diaplay:block' >.


if you want to center, you can use the same value as padding


you can set line-height equal to hieght, to make him center vertically.


display:block does not eliminate the upper margin. I used margin-top:-20px.


is the problem of line break. Newline characters and spaces are identified in the text tag. So you can't write
< text >

{{item.title}}

< / text >

this will identify two lines, and the top line has no content, so it looks like there will be an upper margin

< text > {{item.title}} < / text >

.

Menu