Pure CSS – Varios Leer más Leer menos

Resuelto

Ver código de trabajo en el siguiente fragmento de código. Libre de uso para aquellos que pueden usarlo.

Descripción: hay un contenedor que contiene 10 secciones “Ver más / menos”. Los 11 se pueden plegar y cerrar. Los botones tienen efecto hover. Los textos están en inglés. No Javascript o jQuery. Solución CSS / HTML pura.

Si no necesita los diez, simplemente elimínelos del HTML. No es necesario eliminarlos del CSS.

Como la envoltura es larga, he incluido un botón en la parte inferior del pliegue. Todas las secciones están divididas por una regla horizontal.

Compatible con:

  • Elementos de texto

  • Imágenes
  • Iframes
  • Lado del servidor incluye

Pregunta

Estoy intentando crear un “Leer más / Leer menos” de dos niveles.

El primer nivel debe ocultar / mostrar y envolver una mayor cantidad de información, como imágenes, video y texto. Esta información se dividirá en su propia sección “Leer más / leer menos” y hasta 10 secciones en total que se encuentran dentro del envoltorio.

Sin embargo, estoy teniendo dificultades para crear el segundo nivel, que es parte de la envoltura. Creo que se puede hacer de esta manera pero realmente no puedo hacer que funcione.

 hr { border: 0; border-bottom: 1px dashed #2E181A; background: #2E181A; width: 50%; } /*=============== READ MORE READ LESS ============*/ /******************** Danish **********************/ /*************** See more wrapper *****************/ /**************************************************/ .wrapper-state { display: none; } .wrapper-target { opacity: 0; height: 0; font-size: 0; transition: .25s ease; } .wrapper-state ~ .wrapper-wrap { display: none; } .wrapper-state:checked ~ .wrapper-wrap { display: block; } .wrapper-state:checked ~ .wrapper-wrap .wrapper-target { opacity: 1; font-size: inherit; max-height: 999em; } .wrapper-state ~ .wrapper-trigger:before { content: 'Se mere om hingstene'; } .wrapper-state:checked ~ .wrapper-trigger:before { content: 'Luk afsnit'; } .wrapper-state ~ .wrapper-trigger2:before { content: 'Se mere om hingstene'; display: none; } .wrapper-state:checked ~ .wrapper-trigger2:before { content: 'Luk afsnit'; display: inline-block; } .wrapper-trigger, .wrapper-trigger2 { cursor: pointer; display: block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; text-align: center; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } .wrapper-trigger2:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more first ******/ /*********************/ .first-state{ display: none; } .wrapper-target .first-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .first-state:checked ~ .wrapper-wrap .first-wrap .first-target { opacity: 1; font-size: inherit; max-height: 999em; } .first-state ~ .wrapper-wrap .first-trigger:before { content: 'Se mere'; } .first-state:checked ~ .wrapper-wrap .first-trigger:before { content: 'Se mindre'; } .first-state ~ .first-wrap { display: none; } .first-state:checked ~ .first-wrap { display: block; } .first-target img { height: 0; } .first-state:checked ~ .wrapper-wrap .first-target img { height: auto; } .first-target p { display: none; } .first-state:checked ~ .wrapper-wrap .first-target p { display: block; } .first-target iframe { height: 0; } .first-state:checked ~ .wrapper-wrap .first-target iframe { height: 100%; } .wrapper-wrap .first-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .first-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more second ******/ /*********************/ .second-state{ display: none; } .wrapper-target .second-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .second-state:checked ~ .wrapper-wrap .second-wrap .second-target { opacity: 1; font-size: inherit; max-height: 999em; } .second-state ~ .wrapper-wrap .second-trigger:before { content: 'Se mere'; } .second-state:checked ~ .wrapper-wrap .second-trigger:before { content: 'Se mindre'; } .second-target img { height: 0; } .second-state:checked ~ .wrapper-wrap .second-target img { height: auto; } .second-target p { display: none; } .second-state:checked ~ .wrapper-wrap .second-target p { display: block; } .second-target iframe { height: 0; } .second-state:checked ~ .wrapper-wrap .second-target iframe { height: 100%; } .wrapper-wrap .second-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .second-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more third ******/ /*********************/ .third-state{ display: none; } .wrapper-target .third-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .third-state:checked ~ .wrapper-wrap .third-wrap .third-target { opacity: 1; font-size: inherit; max-height: 999em; } .third-state ~ .wrapper-wrap .third-trigger:before { content: 'Se mere'; } .third-state:checked ~ .wrapper-wrap .third-trigger:before { content: 'Se mindre'; } .third-target img { height: 0; } .third-state:checked ~ .wrapper-wrap .third-target img { height: auto; } .third-target p { display: none; } .third-state:checked ~ .wrapper-wrap .third-target p { display: block; } .third-target iframe { height: 0; } .third-state:checked ~ .wrapper-wrap .third-target iframe { height: 100%; } .wrapper-wrap .third-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .third-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more fourth ******/ /*********************/ .fourth-state{ display: none; } .wrapper-target .fourth-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .fourth-state:checked ~ .wrapper-wrap .fourth-wrap .fourth-target { opacity: 1; font-size: inherit; max-height: 999em; } .fourth-state ~ .wrapper-wrap .fourth-trigger:before { content: 'Se mere'; } .fourth-state:checked ~ .wrapper-wrap .fourth-trigger:before { content: 'Se mindre'; } .fourth-target img { height: 0; } .fourth-state:checked ~ .wrapper-wrap .fourth-target img { height: auto; } .fourth-target p { display: none; } .fourth-state:checked ~ .wrapper-wrap .fourth-target p { display: block; } .fourth-target iframe { height: 0; } .fourth-state:checked ~ .wrapper-wrap .fourth-target iframe { height: 100%; } .wrapper-wrap .fourth-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .fourth-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more fifth ******/ /*********************/ .fifth-state{ display: none; } .wrapper-target .fifth-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .fifth-state:checked ~ .wrapper-wrap .fifth-wrap .fifth-target { opacity: 1; font-size: inherit; max-height: 999em; } .fifth-state ~ .wrapper-wrap .fifth-trigger:before { content: 'Se mere'; } .fifth-state:checked ~ .wrapper-wrap .fifth-trigger:before { content: 'Se mindre'; } .fifth-target img { height: 0; } .fifth-state:checked ~ .wrapper-wrap .fifth-target img { height: auto; } .fifth-target p { display: none; } .fifth-state:checked ~ .wrapper-wrap .fifth-target p { display: block; } .fifth-target iframe { height: 0; } .fifth-state:checked ~ .wrapper-wrap .fifth-target iframe { height: 100%; } .wrapper-wrap .fifth-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .fifth-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more sixth ******/ /*********************/ .sixth-state{ display: none; } .wrapper-target .sixth-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .sixth-state:checked ~ .wrapper-wrap .sixth-wrap .sixth-target { opacity: 1; font-size: inherit; max-height: 999em; } .sixth-state ~ .wrapper-wrap .sixth-trigger:before { content: 'Se mere'; } .sixth-state:checked ~ .wrapper-wrap .sixth-trigger:before { content: 'Se mindre'; } .sixth-target img { height: 0; } .sixth-state:checked ~ .wrapper-wrap .sixth-target img { height: auto; } .sixth-target p { display: none; } .sixth-state:checked ~ .wrapper-wrap .sixth-target p { display: block; } .sixth-target iframe { height: 0; } .sixth-state:checked ~ .wrapper-wrap .sixth-target iframe { height: 100%; } .wrapper-wrap .sixth-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .sixth-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more seventh ******/ /*********************/ .seventh-state{ display: none; } .wrapper-target .seventh-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .seventh-state:checked ~ .wrapper-wrap .seventh-wrap .seventh-target { opacity: 1; font-size: inherit; max-height: 999em; } .seventh-state ~ .wrapper-wrap .seventh-trigger:before { content: 'Se mere'; } .seventh-state:checked ~ .wrapper-wrap .seventh-trigger:before { content: 'Se mindre'; } .seventh-target img { height: 0; } .seventh-state:checked ~ .wrapper-wrap .seventh-target img { height: auto; } .seventh-target p { display: none; } .seventh-state:checked ~ .wrapper-wrap .seventh-target p { display: block; } .seventh-target iframe { height: 0; } .seventh-state:checked ~ .wrapper-wrap .seventh-target iframe { height: 100%; } .wrapper-wrap .seventh-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .seventh-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more eight ******/ /*********************/ .eight-state{ display: none; } .wrapper-target .eight-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .eight-state:checked ~ .wrapper-wrap .eight-wrap .eight-target { opacity: 1; font-size: inherit; max-height: 999em; } .eight-state ~ .wrapper-wrap .eight-trigger:before { content: 'Se mere'; } .eight-state:checked ~ .wrapper-wrap .eight-trigger:before { content: 'Se mindre'; } .eight-target img { height: 0; } .eight-state:checked ~ .wrapper-wrap .eight-target img { height: auto; } .eight-target p { display: none; } .eight-state:checked ~ .wrapper-wrap .eight-target p { display: block; } .eight-target iframe { height: 0; } .eight-state:checked ~ .wrapper-wrap .eight-target iframe { height: 100%; } .wrapper-wrap .eight-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .eight-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more nine ******/ /*********************/ .nine-state{ display: none; } .wrapper-target .nine-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .nine-state:checked ~ .wrapper-wrap .nine-wrap .nine-target { opacity: 1; font-size: inherit; max-height: 999em; } .nine-state ~ .wrapper-wrap .nine-trigger:before { content: 'Se mere'; } .nine-state:checked ~ .wrapper-wrap .nine-trigger:before { content: 'Se mindre'; } .nine-target img { height: 0; } .nine-state:checked ~ .wrapper-wrap .nine-target img { height: auto; } .nine-target p { display: none; } .nine-state:checked ~ .wrapper-wrap .nine-target p { display: block; } .nine-target iframe { height: 0; } .nine-state:checked ~ .wrapper-wrap .nine-target iframe { height: 100%; } .wrapper-wrap .nine-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .nine-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } /****** See more ten ******/ /*********************/ .ten-state{ display: none; } .wrapper-target .ten-target { opacity: 0; max-height: 0; font-size: 0; transition: .25s ease; } .ten-state:checked ~ .wrapper-wrap .ten-wrap .ten-target { opacity: 1; font-size: inherit; max-height: 999em; } .ten-state ~ .wrapper-wrap .ten-trigger:before { content: 'Se mere'; } .ten-state:checked ~ .wrapper-wrap .ten-trigger:before { content: 'Se mindre'; } .ten-target img { height: 0; } .ten-state:checked ~ .wrapper-wrap .ten-target img { height: auto; } .ten-target p { display: none; } .ten-state:checked ~ .wrapper-wrap .ten-target p { display: block; } .ten-target iframe { height: 0; } .ten-state:checked ~ .wrapper-wrap .ten-target iframe { height: 100%; } .wrapper-wrap .ten-trigger { cursor: pointer; display: inline-block; padding: 0 .5em; background-color:#2E181A; color: #E6D9BD; font-size: .9em; line-height: 2; border: 1px solid #E6D9BD; border-radius: 0.5em; } .wrapper-wrap .ten-trigger:hover { border: 1px solid #2E181A; background-color: #E6D9BD; opacity: 1; color:#2E181A; } 
            

What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.


It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.


Why do we use it?

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.


Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).




Where does it come from?

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.


Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.


The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.


The nine riders......


OMFG... Finally at the end!


Cuando hice mi pregunta, seguí trabajando en la solución.

Por favor, encuentre el fragmento en cuestión como la solución de trabajo