Home > Net >  How to style a font in bootstrap
How to style a font in bootstrap

Time:12-03

I have issue styling my font-family using bootstrap. any help thanks

<div >
    <label for="maleFemale">Gender:</label>
    <select name="sex" id="maleFemale">
                        <option value="">Select Gender:</option>
                        <option value="male">Male</option>
                        <option value="female">Female</option>
                    </select>
</div>

CodePudding user response:

Inspect the bootstrap css in your code editor.

You'll see a couple of css variables defining the style defaults:

:root {
  --bs-blue: #0d6efd;
  --bs-indigo: #6610f2;
  --bs-purple: #6f42c1;
  --bs-pink: #d63384;
  --bs-red: #dc3545;
  --bs-orange: #fd7e14;
  --bs-yellow: #ffc107;
  --bs-green: #198754;
  --bs-teal: #20c997;
  --bs-cyan: #0dcaf0;
  --bs-white: #fff;
  --bs-gray: #6c757d;
  --bs-gray-dark: #343a40;
  --bs-primary: #0d6efd;
  --bs-secondary: #6c757d;
  --bs-success: #198754;
  --bs-info: #0dcaf0;
  --bs-warning: #ffc107;
  --bs-danger: #dc3545;
  --bs-light: #f8f9fa;
  --bs-dark: #212529;
  --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
}

In your particular case, you could redefine the --bs-font-sans-serif variable in your main css like so:

:root{
  --bs-font-sans-serif: Arial
}

Make sure your custom css is loaded after bootstrap – otherwise bootstrap will override your custom rules.

If you've already applied your f-Arial class name to HTML elements – just add this class.

.f-Arial{
  font-family: Arial
}

:root{
  --bs-font-sans-serif: Arial
}

.f-Arial{
  font-family: Arial
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<p >Hamburg1234</p>

<div >
  <label for="maleFemale">Gender:</label>
  <select name="sex" id="maleFemale">
    <option value="">Select Gender:</option>
    <option value="male">Male</option>
    <option value="female">Female</option>
  </select>
</div>

CodePudding user response:

you can try this , i believe you can fix your problem. or you can learn from documentation bootstrap, choose your version bootstrap

  • Related