Why text baseline height different when use Tailwind CSS? - tailwind-css

<button type="button" class="flex items-center px-5 py-2 bg-[#152DB5] rounded-[9.9rem]">
<svg><!-- ... --></svg>
<span class="inline-block align-middle text-[1.4rem] font-[700] leading-[2.2rem] tracking-[-0.01em] text-[#fff]">코드 올리기</span>
</button>
Image1
Image2
Hello!
I use Tailwind CSS. Image2 is button that use tailwind CSS. Image1 is button that pure CSS.
Why text baseline height different when use Tailwind CSS?
two span use same font style is
font-size: 1.4rem;
font-weight: 700;
line-height: 20px;
letter-spacing: -0.01em;

Tailwind CSS defines a default line-height for each font-size utility. You can view the default values in the Font Size Documentation Page under properties.
You can also provide a default font-size, line-height, letter-spacing, font-weight and disable the default values by changing them in your tailwind.config.js file: link.
Tailwind’s default theme configures a sensible default line-height for each text-{size} utility. You can configure your own default line heights when using custom font sizes by defining each size using a tuple of the form [fontSize, lineHeight] in your tailwind.config.js file.

Related

Override bootstrap font size

I am using Bootstrap v5.0.2 but I need to override the font size to some custom value.
In the html I am using Click
This gives me some predefined button sizes.
In my main .css file I have:
body{font-size: 22px;}
h1{font-size: 24px;}
I want to match the button font size to the the page font size.
What is the best way to override the font size of the button?
If you want the custom size applied to all .btns then in a stylesheet loaded after BS override the body font size by setting the value of the CSS variable and the .btn font size to use the variable:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<style>
h1 {
font-size: 24px;
}
body {
--bs-body-font-size: 22px;
}
.btn {
font-size: var(--bs-body-font-size);
}
</style>
<h1>
heading
</h1>
<p>
paragraph
</p>
<button class="btn btn-primary">
button
</button>
This will adjust the font size of any element that is based on the var(--bs-body-font-size) value.
There is no need to use !important nor an additional class name (on every single .btn).
I would add a class in your main css file . For Example
.pageButtonSize { font-size: 22px !important; }
and then add the class to your button markup.
Click
you can create your own file.css containing all styles you want to override
then, add this file to your project after bootstrap is added
Note: to make sure your styles will be applied, consider adding !important for each style for example:
h1{
font-size: 50px !important;
}

How to remove computed padding from ion-button when it is disabled

Ionic Button, when disabled appears like it have two background colors in IOS.
I am using ionic button with disabled property like this
<ion-button expand="full" type="submit" [disabled]="!loginForm.valid (click)="login()">Login</ion-button>
Here is how it looks when -
Form is Invalid
Form is valid
On inspecting i found, it’s the COMPUTED padding-inline-start: 16px; and padding-inline-end: 16px; that is causing this kind of background;
I am not using any extra css styling on the button. And this kind of background is visible only when you build the app for ios and run it into simulator or device.
So, How to remove that padding ?
I would recommend to use ngClass combined with a css class:
[ngClass]="!loginForm.valid? 'no-start-end-padding'".
In the css class add !important to overwrite the 16px start and end padding values.
.no-start-end-padding {
padding-inline-start: 16px !important;
padding-inline-end: 16px !important;
}

Forcing font size of bootstrap-select (.selectpicker) element

How can I set the font size of a bootstrap-select to a certain size?
you can give font size to any select just by applying the following css. apply !important to override css loaded after your style.
select {
font-size: 50px !important;
}

font awesome only changes font-size in html, not css

<i class="fa fa-graduation-cap" aria-hidden="true" style="font-size: 50px;"></i>
works
.fa-graduation-cap {
margin-top: 38px;
color: #E46A6B;
font-size: 50px;
}
doesnt work
I've never had this issue before. Any idea?
Yes, I do have the font-awesome css correctly linked.
I believe the font-size is already defined for the icons in the font-awesome.css file. Adding the style tag to the html code overrides these predefined classes. Try typing !important after defining font-size in the css to explicitly override. For example:
.fa-graduation-cap {
margin-top: 38px;
color: #E46A6B;
font-size: 50px !important;
}
Like #developernator stated, you can also use the predefined classes. However, I find that most of the time the right size falls between the sizes of these classes.
The class uses first inline css then internal css and then external css
Your font awesome might have already given inline css either remove inline css or
do-
font-size: 50px !important;

jQuery Mobile selectively override the ui-btn-inner class on buttons?

So it's detailed here on how to remove the padding on buttons by overriding the class on the page: Can the button padding be adjusted in Jquery Mobile?
But how do I take this:
.ui-btn-inner {
padding: 0;}
And selectively apply it to one button, ie:
<button data-icon="false" onclick="alert('clicked me')">Button Name</button>
Doing anything like this doesn't work:
<button style="padding:0" data-icon="false" onclick="alert('clicked me')">Button Name</button>
Thoughts? Creative solutions?
Thanks
Just set a new class for that button and then change subclass as below.
HTML:
<a href"#" data-role="button" class="myClass">Text</a>
CSS:
.myClass .ui-btn-inner{
padding: 0px;
}
I think I have finally found a solution (been trying to figure it out for a while now)!
Use the 'cascading' part of CSS to help you. If your button uses theme 'a' for instance, you can apply the padding rules of .ui-btn-inner to only buttons with theme 'a'. Just prefix the class you are trying to change, with the themed property.
HTML:
<a href"#/mypath" data-role="button" data-theme="a">Touch Me</a>
CSS:
.ui-btn-up-a .ui-btn-inner,
.ui-btn-hover-a .ui-btn-inner,
.ui-btn-down-a .ui-btn-inner
{
padding: 0px;
}
As you can see, this means you have to create the rule for each state of the button, otherwise the padding will return for the split second when you touch the button.
Just apply a different theme (such as 'b') to the buttons that should keep their padding. You can go totally nuts with buttons using this type of CSS inheritance.
You can have an unlimited number of themes. I go to theme roller and create a default theme for every letter of the alphabet. Then, just override them with CSS to my heart's content.
This was a big sticking point when I was trying to use jQuery Mobile for a work project. They already had a UI design and I was tasked with making jQuery Mobile match it exactly.
I just wanted the icon to show with no border or background so I used your example, but the icon was shifted up so I used this to reposition it:
.ui-btn-up-mytheme .ui-btn-inner,
.ui-btn-hover-mytheme .ui-btn-inner,
.ui-btn-down-mytheme .ui-btn-inner {
margin-top: 2px;
border: none;
}
The html markup:
<a href="schedules" data-rel="back" data-icon="arrow-l" data-iconpos="notext"
data-theme="mytheme" data-shadow="false" ></a>

Resources