idcreatv's avatar

Tailwind grid col-span-x not working? Update Tailwind?

Hi folks, just wondering if anyone else is having this issue.

I'm running Laravel 8 and am working in development (thanks to @sinnbeck for helping on a previous question) and all classes are working fine but I can't get a grid with a child div which uses col-span-x (x = number) to actually work. The grid is the correct number of columns but when I apply the col-span-x nothing happens.

I have a snippet which I tested outside of Laravel and it works fine.

That test was using Tailwind v2.2.19 but in my package.json file its set to use "tailwindcss": "^2.0.2". How do I update Laravel's version of Tailwind to v2.2.19? FYI my composer.json and package.json are below.

Thanks for any advice!

package.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "@tailwindcss/aspect-ratio": "^0.4.0",
        "@tailwindcss/forms": "^0.2.1",
        "alpinejs": "^2.7.3",
        "autoprefixer": "^10.1.0",
        "axios": "^0.21",
        "browser-sync": "^2.27.5",
        "browser-sync-webpack-plugin": "^2.3.0",
        "laravel-mix": "^6.0.6",
        "lodash": "^4.17.19",
        "postcss": "^8.2.1",
        "postcss-import": "^12.0.1",
        "resolve-url-loader": "^4.0.0",
        "sass": "^1.37.5",
        "sass-loader": "^12.1.0",
        "tailwindcss": "^2.0.2"
    },
    "dependencies": {
        "@fortawesome/fontawesome-free": "^5.15.4",
        "daisyui": "^1.11.1",
        "tailwind-scrollbar-hide": "^1.1.7"
    }
}

composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "barryvdh/laravel-dompdf": "^0.9.0",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "intervention/image": "^2.6",
        "juliomotol/laravel-auth-timeout": "^3.0",
        "laravel/framework": "^8.54",
        "laravel/tinker": "^2.5",
        "spatie/laravel-honeypot": "^3.0",
        "spatie/laravel-permission": "^4.2",
        "spatie/laravel-query-builder": "^4.0"
    },
    "require-dev": {
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/breeze": "^1.3",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
0 likes
4 replies
Sinnbeck's avatar

Can you show the exact html code that isnt working?

idcreatv's avatar

@Sinnbeck Sure.

This is some boilerplate code which works fine in the browser calling Tailwind from a CDN.

So I know this works. Next I copy the grid code and paste it into Laravel (using dev tools in the browser) and it doesn't work.

Then I copy the https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css link tag and paste it into Laravel (in the browser) and bam - everything works as it should (col-span-x). If I remove that link so I'm using Laravel's own Tailwind it breaks again.

Finally, I've just run npm update again and according to that I have "tailwindcss": "^2.2.19" but the col-span still doesn't work, even after clearing caches. I'm sure I'm probably missing something really simple, but it escapes me exactly what it is.

Here's the code (thanks again)…

P.S. I've not run this in production, just dev, so all the classes should be being called (I'm wise to that after the other thread you helped me with!).

<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title></title>
	<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
	<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
	<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
	<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
</head>

<body>

	<!-- Start site container -->
	<div class="bg-gray-100 h-screen flex content-center">

		<!-- Start page container -->
		<div class="container m-auto bg-blue-500 text-white rounded-3xl p-16">



	<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold col-span-2">1</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">2</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">3</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">4</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">5</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">6</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">7</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">8</div>
		<div class="bg-gray-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">9</div>
	</div>

		</div><!-- End page container -->

	</div><!-- End site container -->

</body>

</html>
idcreatv's avatar

@Snapey Thanks (again) Snapey, that is really informative and should hopefully solve my issues.

Will give this a try and see how I get on.

Please or to participate in this conversation.