0

I have a text and when I press on icon I can read more, and when press on another icon I can read less. The question is that how can make indent of top, for read more and read less icons to see them below than text, and make them(icons) in the center? The icons are +, -.

This is html:

 <p>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. 
<input id="read-more-state-1" class="read-more-state" type="checkbox">
<span class="read-more-target">
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.
</span>
<label for="read-more-state-1" class="read-more-button">
<span class="read-more-button-icon"></span>
</label>
</p>

This is CSS:

.read-more-state {
  display: none;
}

.read-more-button {
  display: none;
}

@media only screen and (max-width: 600px) {   
  .read-more-target {
    opacity: 0;
    font-size: 0;
    transition: .25s ease;
  }

  .read-more-button {
    display: inline-block;
    border-radius: 0.25em;
    width: 1em;
    height: 1em;
    background: url(img/arrow%20grad.svg);
    background-size: cover;
    cursor: pointer;
  }

  .read-more-state:checked + .read-more-target {
    opacity: 1;
    font-size: inherit;
  }

  .read-more-state:checked ~ .read-more-button {
    background: url(img/arrow%20up%20grad.svg);
    background-size: cover;
    cursor: pointer;
  }
}
  • Hello there, so i think if you take a look to this answer you find plenty of ways to customize your checkbox [https://stackoverflow.com/questions/4148499/how-to-style-a-checkbox-using-css] – Giorgio G Dec 18 '18 at 17:27
  • Could you please expand on your question a bit as I do not quite understand it. Are you wanting to have the `+` and `-` _icons_ centered above the text (on top), or below the text? – Mers Dec 18 '18 at 18:25
  • @Mers under text –  Dec 18 '18 at 18:30

1 Answers1

0

If you want the + and - icons to appear centered and below the text, your easiest option would be to make the p element positioned relative, and your icons positioned absolute.

p{
  position: relative;
  padding-bottom: 1.5em;
}
.read-more-button {
  position: absolute;
  bottom: 0px;
  left: 50%;
}

Here is a codepen link.

Mers
  • 736
  • 4
  • 12