Having trouble with col-span not working as expected in Tailwind CSS?

I have a grid layout with 9 buttons using grid-cols-2, leaving the last button in a single column. I want that final button to span across both columns using Tailwind CSS.

Code for .btn :

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
  .btns {
    @apply bg-black w-64 h-14 text-white;
  }
}

Code :

<div class="text-black text-62">
  <p>SHOP</p>
</div>

<div class="flex justify-around items-center">
  <div class="grid grid-cols-4 gap-3">
    <button class="btns">TRULY WIRELESS EARBUDS</button>
    <button class="btns">PREMIUM TWS</button>
    <button class="btns">NEW TWS</button>
    <button class="btns">HEADPHONES</button>
    <button class="btns">GAMING</button>
    <button class="btns">EARBUDS</button>
    <button class="btns">DIME FAMILY</button>
    <button class="btns">BUDGET TWS</button>
    <button class="col-span-2 btns">ANC TWS</button>
  </div>
</div>

The styling works for all buttons, but when trying to apply col-span to the last button alongside the style class .btn, only the style is applied and not the col-span. Apologies for any language errors on my part.

Answer №1

It's important to specify the width in the .btn class.

To make changes for the final button, update the code as follows:

.btns {
    @apply bg-black h-14 text-white;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is the dropdown menu causing issues with the rest of the navigation bar?

While attempting to create my website, I encountered some challenges with the dropdown menu. After following a tutorial on YouTube and making some modifications myself, there seems to be an issue. The screenshot below illustrates that it pulls down the re ...

Rendering HTML5 and CSS3 on Internet Explorer 8

My coding knowledge is limited, but I am conducting research for our front-end developers. Our goal is to revamp our portal application using CSS 3 and HTML 5 in order to achieve an adaptive layout that can accommodate different browser widths. The curre ...

CSS form not aligning properly within wrapper div and appears to be floating outside of it

I am in the process of creating a website that includes a wrapper div containing a: -Header -Content -Footer The issue I am encountering is when I insert regular text into the content section, everything displays properly and the background stretches s ...

What is the best way to generate a complete PDF of a webpage using pdfmake?

I'm currently developing a web application and facing the task of converting an HTML page, which contains multiple tables and datatables, to a PDF format. To achieve this, I've chosen to utilize the library pdfmake. Below is the script that I ha ...

Buttons in the Bootstrap navbar dropdown menu do not display when the navbar is collapsed into a hamburger icon

My bootstrap navbar has a CSS media query that collapses it and allows it to be opened via a hamburger button when the screen size is below a certain threshold (for mobile devices). However, I have encountered an issue with a dropdown menu within the navba ...

adjusting the width of an HTML table cell

I'm struggling with the code below: <table> <thead> <th class='1'>Date</th> <th class='2'>Start Time</th> <th class='3'>End Time </th> <th class='4 ...

Functioning on JSFIDDLE, though facing issues on .html files

I'm baffled. The code snippet below functions perfectly on JSFIDDLE, but it's not working properly on my own webpage. The code is supposed to duplicate everything inside the DIV element. To see it in action, check out this link to the working JSF ...

Transferring data from PHP to an HTML function

I have attempted to retrieve the coordinates generated by the geocode and passed them to the function initialize in order to display a map with the location. Despite transferring the variables from PHP to the function initialize(), it seems that the lati ...

The data within my <ui:define name="content"> element is not displaying on the JSF view

I'm currently working on a project that involves JSF/Facelets and a Style Sheet for styling my JSF view. I'm trying to add some graphical components like "h:inputText" and "h:commandButton" tags to my view XHTML, but for some reason, they are not ...

Guide to pinpointing a location with Google Maps

I am currently working on setting up a contact page that includes Google Maps to show the location of a meeting place. Here is the code I am using: JavaScript (function(){ document.getElementById('map_canvas').style.display="block"; var ...

I'm curious as to why styled components weren't working before

I'm attempting to utilize the before on styled components in React, but it doesn't seem to be functioning correctly. Prior to adding before, the background image was displayed, but after its inclusion, the image is no longer showing up; import st ...

Customizing Autocomplete: Enhancing the selected and set item

My autocomplete function looks like this: $('#' + id).autocomplete({ minLength: minLength, source: function (d, cb) { ... } // select event of OCR number autocompl ...

The current state of my DOM doesn't match the updated value in my model. The update is triggered by a function that is called when a button is clicked

app.controller('thumbnailController', function ($scope) { debugger $scope.customers = [ { name: 'Ave Jones', city: 'Phoenix' }, { name: 'Amie Riley', city: 'Phoenix&ap ...

Adjusting the transparency of the background without altering its colors

I need help figuring out how to merge custom palettes I've created such as this one, which resulted in a .css and .less file. While I want to retain the colors, I also require certain elements' backgrounds to be transparent. To achieve this, I c ...

How can I modify the border color of a Material Ui TextField component?

I've been struggling to figure out how to customize the color of the TextField border. I want to change it from the default grey to black. Below is a simplified version of my UpdatePage.js file: const useStyles = makeStyles(() => ({ updatePage ...

What is the best way to create a timer using JavaScript?

I'm looking for a reverse timer to track session timeout. I found a code on codepen that works as a clockwise timer, but my attempts to make it counterclockwise have failed. Can someone please suggest a solution? I want the timeout to be either 1 hour ...

Clearing selections from a multiple-choice input field

I am seeking to implement a delete feature in a multi-select element similar to the functionality seen here on stackoverflow when selecting multiple tags for a question. Once an item is selected, I would like to display a close icon next to it so that user ...

Retrieving information from the Header element (<H></H>) with the help of Selenium

I have a website with the following code snippet: <div class="list_item_normal"> <div class="main_content"> <div class="img_wrap"> <a href="/home/Detaljer/9781118093757"><img alt="Miniaturebillede af omslaget til Op ...

Concealing buttons and Enabling others using ajax

I am facing a situation where I need to modify the behavior of a modal window on my webpage. The modal currently has two buttons for confirmation and cancellation, as shown in the code snippet below. Inside this modal, there is a <div class = "resp"> ...

I'm encountering a major issue trying to properly position a background image to fill the entire screen

I am struggling to set a background image that fits the entire screen. It looks great on Windows, but when I view the same page on my mobile device (specifically Android using Google Chrome), the image zooms in and out oddly. Additionally, there seems to b ...