3👍
The div
is display:block
by default, which starts the element on its own line, pushing Read more
to the next line.
You could change the div
to a span
, which is display:inline
by default. This assumes that the HTML variable doesn’t contain an element that pushes elements to the next line like the original div
.
If your HTML variable contains display:block
elements (such as div
or p
), you could apply a class to the HTML container that forces its last child element (with :nth-last-child
) to display:inline
:
<template>
<div>
<div class="container" v-html="myHtml"></div>
<a @click="makeMoreTextVisible()">Read more</a>
</div>
</template>
<style>
.container {
display: inline;
}
.container :nth-last-child(1) {
display: inline;
}
</style>
- [Vuejs]-Running some javascript code before rendering in a list
- [Vuejs]-Vuex unknown action type: Nuxtjs
Source:stackexchange.com