Reputation: 1098
I have something that looks like:
<ContentBlock
className={'text-gray-300 mt-4'}
>
Blah blah blah, blah BLAH, blah
<a href="foo.bar"
className={'underline text-gray-200 hover:text-blue-300'}>
foo bar
</a>
</ContentBlock>
When displayed, the href link is always on a newline by itself. How can I make it stay "attached" to the previous text?
Upvotes: 1
Views: 3337
Reputation: 3994
first option:
you can use display: inline-block
for both, a
tag, and the element before
.inline-block {
display: inline-block;
}
<p class="inline-block"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima, !</p>
<a href="" class="inline-block"> learn more</a>
second option:
add the anchor tag inside text tag before it
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima, !
<a href=""> learn more</a>
</p>
third option:
wrap them in flex
.flex {
display: flex;
align-items: center
}
<div class="flex">
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima, !</p>
<a href=""> learn more</a>
</div>
Upvotes: 5
Reputation: 17566
You use Tailwind? Then call the class inline. It is the same like: display: inline-block;
<ContentBlock
className={'text-gray-300 mt-4'}
>
Blah blah blah, blah BLAH, blah
<a href="foo.bar"
className={'inline underline text-gray-200 hover:text-blue-300'}>
foo bar
</a>
</ContentBlock>
Upvotes: 1
Reputation: 95
Something you may consider trying is the adding the CSS "display" property to your element: display: inline-block;
Upvotes: 3