folks,
Please, I'm experimenting with TailwindCSS v2.1. It look great, but I cannot find in documentation this problem.
Please, how can I do the mx-auto in flex for the center object for mobile devices (when 2 pictures cannot be beside) but otherwise I want normal behavior. Yes, I can change the main div in every card from
<div class="mt-5 px-2 md:px-5">
to
<div class="mt-5 px-2 md:px-5 mx-auto">
And it's OK but the last card is centered as well when I have bigger screen (odd cards, last one is always centered). But I want center only when all cards are one under second.
One my card:
<!-- First card -->
<div class="mt-5 px-2 md:px-5">
<div class="max-w-xxs rounded-2xl shadow-md overflow-hidden bg-red-700 text-white">
<figure>
<img class="object-scale-down w-96" src="https://zrebec.sk/assets/tt1.jpg" alt="Man looking at item at a store" />
</figure>
<header class="flex m-2 justify-items-start font-semibold">
<div class="inline-flex items-center border-2 border-black w-20 rounded-md mr-2 px-1">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor">
<path d="M2 10.5a1.5 1.5 0 113 0v6a1.5 1.5 0 01-3 0v-6zM6 10.333v5.43a2 2 0 001.106 1.79l.05.025A4 4 0 008.943 18h5.416a2 2 0 001.962-1.608l1.2-6A2 2 0 0015.56 8H12V4a2 2 0 00-2-2 1 1 0 00-1 1v.667a4 4 0 01-.8 2.4L6.8 7.933a4 4 0 00-.8 2.4z" />
</svg>
<span>186</span>
</div>
<div class="inline-flex items-center border-2 border-black w-20 rounded-md px-1">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor">
<path d="M18 9.5a1.5 1.5 0 11-3 0v-6a1.5 1.5 0 013 0v6zM14 9.667v-5.43a2 2 0 00-1.105-1.79l-.05-.025A4 4 0 0011.055 2H5.64a2 2 0 00-1.962 1.608l-1.2 6A2 2 0 004.44 12H8v4a2 2 0 002 2 1 1 0 001-1v-.667a4 4 0 01.8-2.4l1.4-1.866a4 4 0 00.8-2.4z" />
</svg>
<span>12</span>
</div>
<div class="flex-auto font-bold w-100 text-right">84%</div>
</header>
<article class="m-2">
<h2>Gold Retro</h2>
<p class="text-gray-300 my-2">The Compact Cassette or Musicassette (MC), also commonly called the tape cassette, cassette tape, audio cassette, or simply tape or cassette, is an analog magnetic tape recording format for audio recording and playback. It was developed by the Dutch company Royal Philips in Hasselt, Belgium, by Lou Ottens and his team. It was introduced in September 1963. Compact Cassettes come in two forms, either already containing content as a prerecorded cassette (Musicassette), or as a fully recordable "blank" cassette. Both forms are reversible by the user.</p>
</article>
<footer class="flex items-center h-10 space-x-1 m-2">
<div class="flex-1 text-center text-xs text-white font-semibold bg-green-500 px-3 py-1 rounded-md">Retro</div>
<div class="flex-1 text-center text-xs text-black font-semibold bg-yellow-500 px-3 py-1 rounded-md">Continuous play</div>
<div class="lex-1 text-center text-xs text-black font-semibold bg-red-500 px-3 py-1 rounded-md">Worse quality</div>
</footer>
</div>
</div>
Whole code from playground is here:
https://play.tailwindcss.com/g2Zso9QsCv
Or here in codepen:
https://codepen.io/littleTheRabbit/pen/jOyzrLb
And please, I don't want use Javascript to block mx-auto for last card. I think that flexbox can do that. Specially with Tailwind CSS. Please, try the TailwindCSS solution if is possible. I can write own CSS but then I don't need Tailwind. I want to discover power of TailwindCSS
PS: I added xss size in the config file (otherwise is standard TailwindCSS Code.
Maybe grid does more of what you want.
<div class="grid md:grid-cols-2 lg:grid-cols-3 justify-items-center max-w-5xl mx-auto">
Check our your example using grid:
https://play.tailwindcss.com/89CSaFNmLi
Add justify-center to
<div class="flex flex-wrap gap-5 justify-center">
What about this one?
Change the cointainer <div> to:
<div class="grid justify-items-center sm:grid-cols-2 md:grid-cols-3 lg:flex lg:flex-wrap">
This causes that I will grid with justify-items-center but in large screens I will have wrapped flexbox. Your opinion please?
Related
As the title says, there is whitespace between header and div. Image can be seen below.
Here is a codepen link that recreates the issue: https://codepen.io/pongbao/pen/MWGXLEm
Thanks a lot to those who can help!
<div id="td-div" class="lg:w-1/6 border-2 border-dark-cyan-600 mr-1 mt-1 relative">
<form id="td-form">
<h2
class="text-sm text-center border-b-2 border-dark-cyan-600 bg-dark-cyan-600 py-1 w-full">
Time
Deposit
</h2>
<ul class="text-xs font-roboto-mono">
<li class="pl-1 pt-1">TENOR: 3 MONTHS</li>
<li class="pl-1">RATE: <span id="td-rate">3.0</span>%</li>
<li class="pl-1 my-auto w-full inline-flex"><label for="time-deposit-amount">AMOUNT:
</label><input id="time-deposit-amount"
class="ml-1 px-1 min-w-0 max-w-full shrink border-b border-slate-400 text-xs text-right"
name="time-deposit-amount" type="number" min="1" step="0.01" placeholder="0.00"
required><span id="max-td-amount"
class="hover:cursor-pointer text-2xs my-auto px-1">MAX</span>
</li>
</ul>
<button id="td-button" type="submit"
class="block mx-auto my-2 py-1 px-1.5 rounded text-xs bg-dark-cyan-300 hover:bg-dark-cyan-400"><a
class="inline-flex">Invest<svg fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
class="w-4 h-3 ml-0.5 mt-0.5" viewBox="0 0 24 24">
<path d="M5 12h14M12 5l7 7-7 7"></path>
</svg></a></button>
</form>
</div>
I see this problems in chrome on my screen that has it's dpi set to 125% but not on my other screen where the dpi is set to 100%. I don't seen the problem in firefox at all.
This leads me to think it might be a DPI scaling issue in chrome. Any chance you are using a HiDPI screen?
I'm not sure if there is any good solution for this, but maybe a css on the h2 might work: (maybe not the best solution, but don't know a better one)
position: relative;
top: -1px;
left: -1px;
width: calc(100% + 2px);
Its problem with border-2 which is border-width: 2px; in class list of #td-div. Among others values 2px, 3px, 6px, 7px just leave some space like that . Just change border-2 to border-[2.5px].
I have the following code that creates two <p> tags to store some text:
<p v-if="my_property <= 0" class="text-green-500 text-lg font-bold">{{Math.abs(my_value)}}%</p>
<p v-else class="text-red-500 text-lg font-bold">{{my_value}}%</p>
<div class="inline-block align-bottom bg-yellow-500 align-text-bottom">
<p class="text-gray-500 text-sm ml-1 inline-block align-text-bottom align-bottom">tsa</p>
</div>
I'm trying to have the last <p> tag align bottom as compared to the first. I've tried putting the <p> tag currently in the <div> inside and outside a <div> tag, but I can't seem to get the result right, and it currently looks like this:
I want the "tsa" text to appear here:
What do I need to change about the way I've currently got it?
Note: I've highlighted the <div> in yellow to just show the text is not aligned to the bottom of it.
You can solve your issue by adding a flex-container for all your <p> tags.
<div class="flex items-baseline">
<p v-if="my_property <= 0" class="text-green-500 text-lg font-bold">{{Math.abs(my_value)}}%</p>
<p v-else class="text-red-500 text-lg font-bold">29%</p>
<p class="text-gray-500 text-sm ml-1">tsa</p>
</div>
You can follow the below code for the solution
<script src="https://cdn.tailwindcss.com"></script>
<div v-if="my_property <= 0" class="text-green-500 text-lg font-bold">{{Math.abs(my_value)}}%
<span class="text-gray-500 text-sm ml-1 inline-block align-text-bottom align-bottom">tsa</span>
</div>
<div v-else class="text-red-500 text-lg font-bold">{{my_value}}%
<span class="text-gray-500 text-sm ml-1 inline-block align-text-bottom align-bottom">tsa</span>
</div>
I'm working on this website that is built on React Js and Tailwind. I've made it completely responsive and everything is in working condition however, sometimes when i try to open it in responsive mode on my browser it shows up zoomed in. If i try to exit and enter responsive mode one or two times, it works as intended with no space to move right or left on the webpage. When opening the website on mobile phone however, it shows up zoomed in. It's been two days and i cant get it to work. Phone Display. This is how the site looks like when it's working after entering and exiting responsive mode a couple times. Responsive on Browser. This is how the browser looks like when i try to run it in responsive mode when the bug appears Bad Browser Display
const ComponentCaller = () => { return (
<div className="flex md:min-w-full sm:max-w-screen">
//min-w-[80px] is to create an empty div to leave space for the sidebar
<div className="min-w-[80px] bg-transparent"></div>
<div>
{/*
<div className="bg-one bg-opacity-80 w-screen h-screen -z-50"> */}
<FrontComponent /> {/*
<TestComponent /> */}
<HustleComponent />
<HoverTableComponent />
<AboutUsComponent />
<Contact />
<Footer />
</div>
</div>
) }
This displays all the components
const FrontComponent = () => { return (
<>
<div className="font-body font-extrabold">
<div className="h-full w-full flex flex-col md:flex-row text-lite">
//80 vh height fixed
<div className="flex flex-col justify-center items-center h-[80vh] md:pr-0 sm:pr-6">
<h1 className="font-head text-8xl mr-2 md:pl-12 text-lite leading-tight">
Sample Text
</h1>
<br />
<div className="uppercase text-lite flex flex-col md:flex-row text-lg mt-8 w-max">
<button className="style-1 mt-4 ss:mt-6 rounded-tr-2xl md:mx-4 inline-flex text-base justify-center align-middle w-72 md:w-36 lg:w-48 lg:h-16 h-12">
Get a Quote
<svg
className="fill-lite w-[15px] mx-2 animate-pulse"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path d="M96 480c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L242.8 256L73.38 86.63c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l192 192c12.5 12.5 12.5 32.75 0 45.25l-192 192C112.4 476.9 104.2 480 96 480z" />
</svg>
</button>
<button className="style-1 mt-4 md:mx-4 rounded-tr-2xl inline-flex text-base justify-center align-middle w-72 md:w-36 lg:w-48 lg:h-16 h-12">
Join our Team
</button>
</div>
</div>
<div className="w-[42rem] md:mr-4 ml-16 lg:max-w-[45%] md:w-3/5 md:py-8 my-12 text-center relative grid justify-items-center items-center">
<img src={business} alt='business' />
</div>
</div>
</div>
</> ) }
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 class="grid grid-cols-4 gap-4 services">
<div class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-12.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Report Writing</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-11.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Mentoring</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-10.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Workshops</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-9.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Training</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-8.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Benchmarking</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-7.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Research Services</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-6.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Organisation Development</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="/wp-content/uploads/2022/01/image-5.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Consultancy</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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
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 class="grid grid-cols-4 gap-4 services">
<div class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-12.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Report Writing</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-11.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Mentoring</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-10.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Workshops</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-9.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Training</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-8.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Benchmarking</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-7.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Research Services</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-6.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Organisation Development</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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 class="flex flex-col rounded-md bg-gray-200 p-8 items-center justify-center js-service-click">
<figure class="bg-blue-500 rounded-full flex items-center align-center justify-center w-32 h-32">
<img src="http://davidbakerconsulting.test/wp-content/uploads/2022/01/image-5.svg" class="attachment-full size-full" alt="" loading="lazy"> </figure>
<h2 class="text-lg font-bold mt-7">Consultancy</h2>
<div class="mb-2 text-primary overflow-hidden service-details">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>
I have the following code for my Hugo page for listing out new posts, formatted with Tailwind CSS:
{{ define "main" }}
{{ range .Pages }}
<div class="grid grid-flow-row grid-cols-3">
<div class="flex justify-center">
<div class="bg-white shadow-xl rounded-lg overflow-hidden">
<div class="bg-cover bg-center h-56 p-4" style="background-image: url(https://ui-avatars.com/api/?name=John+Doe&size=512)">
<div class="flex justify-end">
</div>
</div>
<div class="p-4">
<p class="uppercase tracking-wide text-sm font-bold text-gray-700">{{ .Params.Major}}</p>
<p class="text-3xl text-gray-900 font-bold">{{ .Title }}</p>
<p class="text-gray-700">A small description and a bucnch of stuff.</p>
</div>
<div class="flex p-4 border-t border-gray-300 text-gray-700">
<div class="flex-1 inline-flex items-center">
<svg class="h-6 w-6 text-gray-600 fill-current mr-3" viewBox="0 0 20 20">
<path d="M15.573,11.624c0.568-0.478,0.947-1.219,0.947-2.019c0-1.37-1.108-2.569-2.371-2.569s-2.371,1.2-2.371,2.569c0,0.8,0.379,1.542,0.946,2.019c-0.253,0.089-0.496,0.2-0.728,0.332c-0.743-0.898-1.745-1.573-2.891-1.911c0.877-0.61,1.486-1.666,1.486-2.812c0-1.79-1.479-3.359-3.162-3.359S4.269,5.443,4.269,7.233c0,1.146,0.608,2.202,1.486,2.812c-2.454,0.725-4.252,2.998-4.252,5.685c0,0.218,0.178,0.396,0.395,0.396h16.203c0.218,0,0.396-0.178,0.396-0.396C18.497,13.831,17.273,12.216,15.573,11.624 M12.568,9.605c0-0.822,0.689-1.779,1.581-1.779s1.58,0.957,1.58,1.779s-0.688,1.779-1.58,1.779S12.568,10.427,12.568,9.605 M5.06,7.233c0-1.213,1.014-2.569,2.371-2.569c1.358,0,2.371,1.355,2.371,2.569S8.789,9.802,7.431,9.802C6.073,9.802,5.06,8.447,5.06,7.233 M2.309,15.335c0.202-2.649,2.423-4.742,5.122-4.742s4.921,2.093,5.122,4.742H2.309z M13.346,15.335c-0.067-0.997-0.382-1.928-0.882-2.732c0.502-0.271,1.075-0.429,1.686-0.429c1.828,0,3.338,1.385,3.535,3.161H13.346z"></path>
</svg>
<p><span class="text-gray-900 font-bold">3rd</span> Year</p>
</div>
<div class="flex-1 inline-flex items-center">
<svg class="h-6 w-6 text-gray-600 fill-current mr-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M17.03 21H7.97a4 4 0 0 1-1.3-.22l-1.22 2.44-.9-.44 1.22-2.44a4 4 0 0 1-1.38-1.55L.5 11h7.56a4 4 0 0 1 1.78.42l2.32 1.16a4 4 0 0 0 1.78.42h9.56l-2.9 5.79a4 4 0 0 1-1.37 1.55l1.22 2.44-.9.44-1.22-2.44a4 4 0 0 1-1.3.22zM21 11h2.5a.5.5 0 1 1 0 1h-9.06a4.5 4.5 0 0 1-2-.48l-2.32-1.15A3.5 3.5 0 0 0 8.56 10H.5a.5.5 0 0 1 0-1h8.06c.7 0 1.38.16 2 .48l2.32 1.15a3.5 3.5 0 0 0 1.56.37H20V2a1 1 0 0 0-1.74-.67c.64.97.53 2.29-.32 3.14l-.35.36-3.54-3.54.35-.35a2.5 2.5 0 0 1 3.15-.32A2 2 0 0 1 21 2v9zm-5.48-9.65l2 2a1.5 1.5 0 0 0-2-2zm-10.23 17A3 3 0 0 0 7.97 20h9.06a3 3 0 0 0 2.68-1.66L21.88 14h-7.94a5 5 0 0 1-2.23-.53L9.4 12.32A3 3 0 0 0 8.06 12H2.12l3.17 6.34z"></path>
</svg>
<p><span class="text-gray-900 font-bold"></span> Programming</p>
</div>
</div>
<div class="px-4 pt-3 pb-4 border-t border-gray-300 bg-gray-100">
<div class="text-xs uppercase font-bold text-gray-600 tracking-wide">Made By</div>
<div class="flex items-center pt-2">
<div>
<p class="font-bold text-gray-900">Aman Bhargava</p>
</div>
</div>
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
What I want is to have three columns of cards, with each new post being added left to right in the columns before adding a new row below. However, my code gives me a stacked listing instead of the expected output:
I would like something like this:
1st Column
2nd Column
3rd Column
First Post
Second Post
Third Post
Fourth Post
Fifth Post
Sixth Post
The problem is that the range function is outside the grid, so it's creating a new grid for each card. You probably want just one grid, with all the cards placed within it.
If you move your range function inside the grid, so that it iterates only over the cards, e.g.:
{{ define "main" }}
<div class="grid grid-flow-row grid-cols-3">
{{ range .Pages }}
<div class="flex justify-center">
<div class="bg-white shadow-xl rounded-lg overflow-hidden">
<!-- content -->
</div>
</div>
{{ end }}
</div>
{{ end }}
then you should get the expected behaviour.