Command "see more"

Asked

Viewed 1,598 times

0

I have a mobile page, it has enough texts with various information on such a subject, with a few paragraphs, I wonder if there is a way to leave a paragraph of each subject in view with three dots and the option "...see more" to display the other paragraphs if it is in the user’s interest.

  • It would be interesting to quote the programming language used and some excerpt you have tried so we can help you

  • html and css, and the code I got nothing yet!

  • html is not programming language but markup and css is for styles, so it would be interesting to start using a language or if it is to keep in html it would have to be done at hand even inserting a button at the end of the paragraph directing to another page with the full text.

  • I’m wanting to hide on the same page, without directing to another, you know the name of this function in php, for me to search about?

  • You can put the full content inside another div leave it as Hide and when javascript-clicking a show

  • I’ll do some research, when you have some update I put here.

  • It would be interesting to post a part of your HTML where you want to do this so we know what kind of resources you are using.

Show 2 more comments

1 answer

2

For who uses jQuery there is a plugin ready to facilitate the work:

For those who use React there are also solutions, one I found was:

If you want to create something manually, I made an example very simple using position: relative; combined with absolute and Javascript (classList.toggle), something like that:

var morelinks = document.querySelectorAll(".section > .txt-more");

for (var i = 0, j = morelinks.length; i < j; i++) {
     morelinks[0].onclick = function () {
          var container = this.parentNode.querySelector(".container");
          
          container.classList.toggle("partial");
          this.classList.toggle("txt-more");
     };
}
.section {
    position: relative;
    background: #fff;
}

.section > .txt-more {
    display: block;
    background: #fff;

    /*posiciona o link no final da DIV*/
    position: absolute;
    right: 0;
    bottom: 0;
}

.section > .partial {
    height: 200px; /* limita a altura aqui, assim irá limitar o texto*/
    overflow: hidden;
}

.section > a::before {
    content: "Ocultar"; /*Texto de quando o texto estiver visivel*/
}

.section > a.txt-more::before {
    content: "... Mostrar mais"; /* texto para o link*/
}
<div class="section">
    <div class="container partial">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur finibus, velit sed convallis elementum, lacus lectus hendrerit quam, sed vulputate justo nisi eu purus. Proin et finibus nisi, sed fringilla est. Sed turpis ex, ullamcorper vel molestie id, faucibus ut lacus. Aenean neque nisl, ullamcorper ac commodo eget, sagittis vitae nulla. Vestibulum eget nisl non massa blandit pretium. Vivamus euismod mattis aliquet. Sed nec lorem in nulla tincidunt faucibus. Sed sem mi, vestibulum id nisl et, pellentesque vulputate nulla. Aenean ut diam efficitur, pulvinar purus id, auctor nibh. Nam sodales scelerisque maximus. Morbi aliquam arcu sit amet accumsan commodo.

In id consequat metus. Pellentesque accumsan leo scelerisque libero elementum sagittis. Maecenas eget libero hendrerit, semper purus pulvinar, consequat turpis. Ut quam erat, laoreet vitae volutpat nec, lacinia nec elit. Etiam eu condimentum metus. Mauris id venenatis quam. Morbi id ex enim. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque consequat blandit odio, porttitor sagittis turpis euismod eu. Maecenas luctus elit a consequat convallis. Morbi ultricies, ligula a iaculis suscipit, est justo pharetra purus, nec interdum elit libero eu metus. Maecenas aliquet enim id ipsum fermentum, quis vulputate sapien lobortis. Morbi id mauris tincidunt urna porttitor posuere. Curabitur a purus sit amet lorem dictum blandit sed sit amet nunc. Nulla et lorem non eros porta consequat vitae quis lacus. Aenean faucibus efficitur sem vitae faucibus.

Morbi quis mi posuere, vehicula quam nec, scelerisque est. Mauris vitae nisl et arcu consequat tristique. Nulla vitae scelerisque ex. Fusce ultrices lacus vel vehicula mollis. Cras facilisis sapien dictum neque placerat, vitae pretium lectus tincidunt. Donec eget euismod velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean vitae magna tempus, tincidunt dui eu, imperdiet augue. In dictum lacus at lorem egestas, vel commodo purus ullamcorper. Ut vitae nisi hendrerit, lacinia leo a, vulputate quam. Etiam ac ante urna. Nullam ut sem vel turpis placerat accumsan. Donec nec consequat sem.
    </div>
    <a class="txt-more" href="javascript:void(0);"></a>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.