Padding and margin are not working on Vue.js _ TW v4.0 #15728
-
I have initialized a new project and installed the necessary packages, including Tailwind CSS v4.0. However, when I began creating a component, the padding and margin styles were not applying as expected. I verified that everything was installed correctly according to the documentation. I need assistance in resolving this issue. At one point, I prefixed the padding and margin classes with the '!' modifier, and they worked. How can I achieve the same effect without using the '!' modifier? Here’s the code.
and I have installed vuetify |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
I had a similar issue where a lot of my styles seemed to be alright but margin and padding were obviously very wrong. In v3, my main CSS file had reset styles like the ones below. I like to reset all margin and padding to 0 and handle those manually for each element and this worked fine in v3. I think v4 brought quite a few specificity changes because of the substantial use of CSS @tailwind base;
@tailwind components;
@tailwind utilities;
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
}
html {
font-family: sans-serif;
color: #333;
} To fix things all I had to do was move my reset styles into @import 'tailwindcss';
@layer base {
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
}
html {
font-family: sans-serif;
color: #333;
}
} I figured this out reading this section of the v4 docs |
Beta Was this translation helpful? Give feedback.
-
Thank you so much. It worked for me. |
Beta Was this translation helpful? Give feedback.
-
Thank you this worked for me top |
Beta Was this translation helpful? Give feedback.
I had a similar issue where a lot of my styles seemed to be alright but margin and padding were obviously very wrong. In v3, my main CSS file had reset styles like the ones below. I like to reset all margin and padding to 0 and handle those manually for each element and this worked fine in v3. I think v4 brought quite a few specificity changes because of the substantial use of CSS
@layer
and this made it so all my elements always had 0 margin and padding, even when using a tailwind class like<div class="p-4"></div>
.