admin管理员组文章数量:1435090
I'm trying to add a space between span and text in React but it seems it behaves differently in JSX? here is the code
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{`${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
As you can see {timeOfDay} which is good night is sticking to the text, what im trying to do is have a space between them, how can i achieve that in React?
I'm trying to add a space between span and text in React but it seems it behaves differently in JSX? here is the code
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{`${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
As you can see {timeOfDay} which is good night is sticking to the text, what im trying to do is have a space between them, how can i achieve that in React?
Share Improve this question asked Feb 6, 2019 at 17:40 AshrafAshraf 651 silver badge9 bronze badges1 Answer
Reset to default 4There are multiple ways to add space between elements in JSX
- Use
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{`${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
- Use
{' '}
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{` ${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
- Use CSS(padding/margin to span)
本文标签: javascriptReact span space in between textStack Overflow
版权声明:本文标题:javascript - React span space in between text - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745649477a2668338.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论