I have a css grid layout that looks like this,
When a box is clicked is grows in height to show information about the service. What I was hoping to be able to do was the "relayout" the grid so grid wrapped around the tallest item? Instead what I have is when I an item grows that row and it's children grow with it.
What I was hoping for was if report writing was clicked it would grow and take up benchmarking space, benchmarking would move left and consultancy would wrap onto a new line?
I am using tailwind so my HTML looks like this,
<div >
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-12.svg" alt="" loading="lazy"> </figure>
<h2 >Report Writing</h2>
<div >DBC can provide reports on any activity for organisations wishing to change any aspect of its operation or strategic direction. David has written consultancy reports for many countries on library and information transformation projects, various institutions seeking to gain taught degree awarding powers (TDAP), leadership and management benchmarking exercises and organisational training provision.
Notable recent examples include three reports written for for SCONUL to assess the strategic role of libraries and their leaders from the viewpoint of the universities’ senior management. This resulted in a publication for the commissioning body SCONUL to highlight the expectations of university leadership in the development of relevant library strategies. As a further phase of this work, Alison Allden and David Baker looked at the opportunities and transferable skills relating to international movement amongst library leaders.
David has been working with the University of London since March 2020 to develop a new strategy for Senate House Library, along with the School of Advanced Study, Federal Member Institute Libraries and the University of London Worldwide. The initial report was accepted by the University in September 2020. In the light of this, David has created a major Library Transformation Programme (LTP). The work involved in developing and operationalising the report included surveys, benchmarking, focus groups and workshops.</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-11.svg" alt="" loading="lazy"> </figure>
<h2 >Mentoring</h2>
<div >David has experience of mentoring professionals from different sectors and academics reaching back to 1990. He is currently heavily involved in mentoring for CILIP Chartership, Certification and Fellowship status (the UK’s library and information association). The focus is on developing and nurturing staff while learning new ideas and approaches from other professionals. Mentoring can be undertaken in person, by email, by telephone or through online platforms.</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-10.svg" alt="" loading="lazy"> </figure>
<h2 >Workshops</h2>
<div >DBC has a wealth of experience in delivering face-to-face and online workshops for a range of projects and purposes. These can be for the purpose of stakeholder engagement, data gathering or as part of a communications strategy. Workshops, interviews and focus groups are carried out consistently and coherently to give maximum value of data and information gathered. This is done through agreed pro forma and protocols.</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-9.svg" alt="" loading="lazy"> </figure>
<h2 >Training</h2>
<div >The DBC team can offer project management and change management training using previous live (anonymised) projects. A DBC Associate is PRINCE2 trained.
David Baker has delivered training in library management and information systems for senior leaders, library tecnhnicians and assistants for many countries of the world including, Slovenia, Ireland, Kuwait, Hungary, Germany and Portugal and has published several training guides, including on the subject of co-operative training in this area. He has also provided training and development for third world countries such as Ethiopia and Nigeria and has published a book on this.</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-8.svg" alt="" loading="lazy"> </figure>
<h2 >Benchmarking</h2>
<div >In 2022, DBC is undertaking a major international benchmarking exercise based on the Association of Commonwealth Universities (ACU) model. It is being led by David, Caroline (Librarian of the University of Queensland for academic and research libraries in the Australia and South Pacific region), Cliff and Lucy. The title is "Benchmarking Library, Information And Education Services: New Strategic Choices In Challenging Times". An Elsevier book publication bearing the same title will be published in early 2023. The benchmarking model can be adapted for any organisational purpose.</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-7.svg" alt="" loading="lazy"> </figure>
<h2 >Research Services</h2>
<div >DBC Associates worked in 2021 on a scoping study commissioned by Research Libraries UK (RLUK) and funded by the Arts and Humanities Research Council (AHRC). It resulted in a wealth of evidence of the role and potential of research libraries as partners and leaders of research, contributing to longer-term strategic development in the process. A range of research techniques were used for this and other consultancies such as surveys, benchmarking, focus groups and workshops. Two senior associates have research backgrounds and PhDs and the Director, Professor, has a substantial and significant track record in research and publishing.</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-6.svg" alt="" loading="lazy"> </figure>
<h2 >Organisation Development</h2>
<div >DBC has been developing strategic plans at organisational and pan-organisational levels for many years, not least through working in chief executive and governance roles as well as high-level consultancy work. We are accustomed to working with governing bodies, steering committees, task forces and other groupings to shape strategic direction and effect major organisational change as a result.
Our biographical details demonstrate that we have developed, written and implemented many strategic plans, including for the Higher Education Statistics Agency (HESA) and the Joint Information Systems Committee (Jisc), as well as contributing to strategy development for the Society of College, National and University Libraries (SCONUL) and Research Libraries UK (RLUK).</div>
</div>
<div >
<figure >
<img src="/wp-content/uploads/2022/01/image-5.svg" alt="" loading="lazy"> </figure>
<h2 >Consultancy</h2>
<div >DBC delivers high-quality consultancy projects in higher education both nationally and internationally, with a long-standing track record, especially in strategy development. Associates have a broad and deep knowledge of the field.</div>
</div>
</div>
Here is a codepen of my current solution
CodePudding user response:
A couple of things.
You can make the clicked item span two rows by setting grid-row: span 2 This will have the effect of 'pushing' other grid items around.
In the JS you had a call to remove which I think should have been removeClass
Here's a (slightly messy) SO snippet created from your codepen:
<head>
<meta charset="UTF-8">
<link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png">
<meta name="apple-mobile-web-app-title" content="CodePen">
<link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico">
<link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-8f3771b1072e3c38bd662872f6b673a722f4b3ca2421637d5596661b4e2132cc.svg" color="#111">
<head>
<title>CodePen - A Pen by Simon Ainley</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css">
<style>
.service-details {
overflow: hidden;
max-height: 0;
transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
}
.service-details.service-content-visible {
max-height: 300px;
grid-row: span 2;
transition: max-height 1s ease-in-out;
}
</style>
<script>
window.console = window.console || function(t) {};
</script>
<script>
if (document.location.search.match(/type=embed/gi)) {
window.parent.postMessage("resize", "*");
}
</script>
<style>
.service-details {
overflow: hidden;
max-height: 0;
transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
}
.service-details.service-content-visible {
max-height: 300px;
transition: max-height 1s ease-in-out;
}
</style>
</head>
<div >
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-12.svg" alt="" loading="lazy"> </figure>
<h2 >Report Writing</h2>
<div >DBC can provide reports on any activity for organisations wishing to change any aspect of its operation or strategic direction. David Baker has written consultancy reports for many countries on library and information transformation projects, various
institutions seeking to gain taught degree awarding powers (TDAP), leadership and management benchmarking exercises and organisational training provision. Notable recent examples include three reports written for for SCONUL to assess the strategic
role of libraries and their leaders from the viewpoint of the universities’ senior management. This resulted in a publication for the commissioning body SCONUL to highlight the expectations of university leadership in the development of relevant
library strategies. As a further phase of this work, Alison Allden and David Baker looked at the opportunities and transferable skills relating to international movement amongst library leaders. David Baker has been working with the University
of London since March 2020 to develop a new strategy for Senate House Library, along with the School of Advanced Study, Federal Member Institute Libraries and the University of London Worldwide. The initial report was accepted by the University
in September 2020. In the light of this, David has created a major Library Transformation Programme (LTP). The work involved in developing and operationalising the report included surveys, benchmarking, focus groups and workshops.</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-11.svg" alt="" loading="lazy"> </figure>
<h2 >Mentoring</h2>
<div >Professor David Baker has experience of mentoring professionals from different sectors and academics reaching back to 1990. He is currently heavily involved in mentoring for CILIP Chartership, Certification and Fellowship status (the UK’s library
and information association). The focus is on developing and nurturing staff while learning new ideas and approaches from other professionals. Mentoring can be undertaken in person, by email, by telephone or through online platforms.</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-10.svg" alt="" loading="lazy"> </figure>
<h2 >Workshops</h2>
<div >DBC has a wealth of experience in delivering face-to-face and online workshops for a range of projects and purposes. These can be for the purpose of stakeholder engagement, data gathering or as part of a communications strategy. Workshops, interviews
and focus groups are carried out consistently and coherently to give maximum value of data and information gathered. This is done through agreed pro forma and protocols.</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-9.svg" alt="" loading="lazy"> </figure>
<h2 >Training</h2>
<div >The DBC team can offer project management and change management training using previous live (anonymised) projects. A DBC Associate is PRINCE2 trained. David Baker has delivered training in library management and information systems for senior leaders,
library tecnhnicians and assistants for many countries of the world including, Slovenia, Ireland, Kuwait, Hungary, Germany and Portugal and has published several training guides, including on the subject of co-operative training in this area.
He has also provided training and development for third world countries such as Ethiopia and Nigeria and has published a book on this.</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-8.svg" alt="" loading="lazy"> </figure>
<h2 >Benchmarking</h2>
<div >In 2022, DBC is undertaking a major international benchmarking exercise based on the Association of Commonwealth Universities (ACU) model. It is being led by David Baker, Caroline Williams (Librarian of the University of Queensland for academic
and research libraries in the Australia and South Pacific region), Cliff Wragg and Lucy Ellis. The title is "Benchmarking Library, Information And Education Services: New Strategic Choices In Challenging Times". An Elsevier book publication bearing
the same title will be published in early 2023. The benchmarking model can be adapted for any organisational purpose.</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-7.svg" alt="" loading="lazy"> </figure>
<h2 >Research Services</h2>
<div >DBC Associates worked in 2021 on a scoping study commissioned by Research Libraries UK (RLUK) and funded by the Arts and Humanities Research Council (AHRC). It resulted in a wealth of evidence of the role and potential of research libraries as partners
and leaders of research, contributing to longer-term strategic development in the process. A range of research techniques were used for this and other consultancies such as surveys, benchmarking, focus groups and workshops. Two senior associates
have research backgrounds and PhDs and the Director, Professor Baker, has a substantial and significant track record in research and publishing.</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-6.svg" alt="" loading="lazy"> </figure>
<h2 >Organisation Development</h2>
<div >DBC has been developing strategic plans at organisational and pan-organisational levels for many years, not least through working in chief executive and governance roles as well as high-level consultancy work. We are accustomed to working with governing
bodies, steering committees, task forces and other groupings to shape strategic direction and effect major organisational change as a result. Our biographical details demonstrate that we have developed, written and implemented many strategic plans,
including for the Higher Education Statistics Agency (HESA) and the Joint Information Systems Committee (Jisc), as well as contributing to strategy development for the Society of College, National and University Libraries (SCONUL) and Research
Libraries UK (RLUK).</div>
</div>
<div >
<figure >
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-5.svg" alt="" loading="lazy"> </figure>
<h2 >Consultancy</h2>
<div >DBC delivers high-quality consultancy projects in higher education both nationally and internationally, with a long-standing track record, especially in strategy development. Associates have a broad and deep knowledge of the field.</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$('.services').on('click', '.js-service-click', function(e) {
$('.row-span-2').removeClass('row-span-2');
$(this).addClass('row-span-2');
$('.service-content-visible').removeClass('service-content-visible');
$(this).find('.service-details').toggleClass('service-content-visible');
});
</script>

