Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Sort the tags content by mobile & desktop breakpoint

I wonder how can I order my divs basing on mobile and desktop breakpoints. I have:

<div>
    <span> foo </span>
    <span> bar </span>
    <span> baz </span>
</div>

I would like to reach a result in which:

only on mobile breakpoint firstspan & secondspan are on the same line, so:

foobar
baz

and only on desktop breakpoint secondspan & thirdspan are on the same line, so:

foo
barbaz

I usually use Tailwind (but I think this information is irrelevant), I tried with flex, break-line but nothing, I don't understand how to create this code.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To achieve this using tailwindCSS, you can use grid and make col-span responsive.

In below example, firstspan & secondspan are on first line until small breakpoint, and for screen bigger than small, firstspan is alone on its line and secondspan and thirdspan are on the same line.

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<div class="grid grid-cols-2">
  <div class="sm:col-span-2">First span</div>
  <div>Second span</div>
  <div>Third span</div>
</div>


Edited after comment from @davide

To have the elements on the same line, the easiest solution would be to repeat the secondspan twice, and use responsive breakpoints with display classes to hide or display it depending on the screen size.

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<div>
  <span>First span</span>
  <span class="sm:hidden">Second span</span>
</div>
<div>
  <span class="hidden sm:inline">Second span</span> 
  <span>Third span</span>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!