The case can be like this – for example, from the main page you need to place links to an internal page where a list of questions and answers is placed. On the inner page, the link should expand the answer to a specific question.
The solution is here:
HTML code:
<div class="info"><span class="target-fix" id="info"></span> <!-- 1 Block --> <div><span class="target-fix" id="info1"></span> <a href="#info1" id="open-info1" title="open">text 1</a> <a href="#info" id="close-info1" title="close">text 1</a> <div class="info-content"> <p>text 1 text 1</p> </div> </div> <!-- 2 Block --> <div><span class="target-fix" id="info2"></span> <a href="#info2" id="open-info2" title="open">test 2</a> <a href="#info" id="close-info2" title="close">text 2</a> <div class="info-content"> <p>text 2 text 2</p> </div> </div> <!-- 3 Block --> <div><span class="target-fix" id="info3"></span> <a href="#info3" id="open-info3" title="open">test 3</a> <a href="#info" id="close-info3" title="close">test 3</a> <div class="info-content"> <p>text 3 text 3</p> </div> </div> <!-- 4 Block --> <div><span class="target-fix" id="info4"></span> <a href="#info4" id="open-info4" title="open">test 4</a> <a href="#info" id="close-info4" title="close">test 4</a> <div class="info-content"> <p>text 4 text 4</p> </div> </div> <!-- 5 Block --> <div><span class="target-fix" id="info5"></span> <a href="#info5" id="open-info5" title="open">test 5</a> <a href="#info" id="close-info5" title="close">test 5</a> <div class="info-content"> <p>text 5 text 5</p> </div> </div> </div>
CSS code:
.info {
max-width: 1240px;
position: relative;
margin: 60px auto;
width: 100%;
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 15%);
border-radius: 5px;
}
[id*=open-info], [id*=close-info] {
background: #fff;
border-bottom: 1px solid #fff;
line-height: 30px;
height: auto;
display: block;
margin: 0 auto;
position: relative;
width: 100%;
}
[id*=close-info] {
display: none;
}
.info a {
color: #2b3846;
}
.info a[title="open"], .info a[title="close"] {
font-size: 1.25em;
font-weight: normal;
padding-left: 55px;
text-decoration: none;
text-shadow: none;
padding-top: 20px;
padding-bottom: 20px;
font-size: 30px;
line-height: 34px;
font-weight: 900;
}
[id*=open-info]:after , [id*=close-info]:after {
content: '';
position: absolute;
width: 12px;
height: 12px;
border-right: 2px solid #9ba4ad;
border-bottom: 2px solid #9ba4ad;
left: 30px;
top: 50%;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
margin: -6px 0 0 -5px;
-webkit-transition: .4s;
transition: .4s;
}
[id*=close-info]:after {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
margin-top: -8px;
}
.target-fix {
display: block;
top: 0;
left: 0;
position: fixed;
}
.info-content {
background: #fff;
height: 0;
margin: -1px auto 0;
padding: 0 2.5%;
position: relative;
overflow: hidden;
width: 100%;
transition: all 0.1s ease;
-webkit-transition: all 0.1s ease;
-moz-transition: all 0.1s ease;
border-bottom: 1px solid #eee;
font-size: 18px;
line-height: 24px;
padding-left: 55px;
}
.info span:target ~ .info-content {
display: block;
height: auto;
padding-bottom: 25px;
padding-top: 10px;
}
.info span:target ~ [id*=close-info] {
display: block;
}
.info span:target ~ [id*=open-info] {
display: none;
}
WEBinP Your guide to resolving CMS optimization, Web Development and SEO problems