Forum Moderators: open

Message Too Old, No Replies

How to add a plus sign which when clicked shows more content ?

         

born2run

6:08 pm on Dec 13, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi so I'm not sure if this is done via CSS or Javascript (or both). If you visit this popular UK news aggregator website newzit dot com, you'll notice below each news article there is a plus sign (See More Versions). If you click on the Plus sign then it shows a dropdown within the page of more links with similar news topic.

Can anyone please let me know how this is coded via JS or CSS or both? Thanks much in advance!

not2easy

6:56 pm on Dec 13, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You would need more than the button to make it show anything when clicked. The button is part of the package but it does not work without the whole package.

It is a free script available in several places, you can find it at w3schools in their slideshow examples and maybe adapt it to your purposes.

coothead

8:48 pm on Dec 13, 2021 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hi there born2run,

here is a CSS example...

<!DOCTYPE HTML>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

<title>CSS See More Example</title>

<!--
The internal CSS should be transferred to an external file
<link rel="stylesheet" href="screen.css" media="screen">
-->

<style media="screen">
body {
background-color: #f0f0f0;
font: normal 1em / 1.5em sans-serif;
}
h1 {
font-size: 1.5em;
color: #555;
text-align: center;
}
#container {
display: flex;
flex-direction: column;
padding: 1em;
}
#container input {
position: absolute;
left: -999em;
}
#container input:checked + label::after {
content: '\2212';
}
#container input:checked + label span {
opacity: 0;
}
#container input:checked + label + div {
display: block;
}
#container label {
display: block;
max-width: 13em;
margin: 0.5em 0;
cursor: pointer;
}
label::after{
content: '\0002b';
display: inline-block;
padding: 0 0.35em;
margin-left: 0.5em;
border-radius: 50%;
background-color: #888;
color: #fff;
}
label:hover::after,
label:active::after {
background-color: #f00;
}
label:hover span,
label:active span {
color: #f00;
}
#container div {
display: none;
max-width: 50em;
padding: 1em 2em;
border: 1px solid #999;
border-radius: 0.75em;
background-color: #fff;
}
</style>

</head>
<body>

<h1>CSS See More Example</h1>

<div id="container">
<input id="cb1" type="checkbox">
<label for="cb1"><span>See more versions</span></label>
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Amet consectetur adipiscing elit ut aliquam. Quis lectus nulla
at volutpat. Habitasse platea dictumst vestibulum rhoncus est
pellentesque elit ullamcorper. Commodo nulla facilisi nullam
vehicula ipsum a arcu cursus vitae.
</p>
</div>

<input id="cb2" type="checkbox">
<label for="cb2"><span>See more versions</span></label>
<div>
<p>
Pharetra sit amet aliquam id. Purus faucibus ornare suspendisse
sed nisi. Et ultrices neque ornare aenean euismod elementum nisi
quis. Dolor morbi non arcu risus quis varius. Habitant morbi
tristique senectus et netus. Lectus sit amet est placerat in
egestas erat imperdiet sed. Leo integer malesuada nunc vel. Nibh
mauris cursus mattis molestie a.
</p>
</div>
<!-- #container --></div>

</body>
</html>


birdbrain

NickMNS

10:17 pm on Dec 13, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This has been discussed before and multiple solutions were provided.

My search of the forums found this:
[webmasterworld.com...]

I'm pretty sure there is more, maybe others here will be able to find the threads.

coothead

10:40 pm on Dec 13, 2021 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hi there born2run,

I was unaware that this forum permitted Codepen links,
but as it does you can see a working example here...

Full Page View:-

[codepen.io ]

Editor View:-

[codepen.io ]

birdbrain

born2run

4:11 am on Dec 14, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hey thanks much! Really appreciate all the tips :-)