0

In each bootstrap 4 CSS files, we have :root selector like

:root {
  --blue: #007bff;
  --indigo: #6610f2;
  --purple: #6f42c1;
  --pink: #e83e8c;
  --red: #dc3545;
  --orange: #fd7e14;
  --yellow: #ffc107;
  --green: #28a745;
  --teal: #20c997;
  --cyan: #17a2b8;
  --white: #fff;
  --gray: #868e96;
  --gray-dark: #343a40;
  --primary: #007bff;
  --secondary: #868e96;
  --success: #28a745;
  --info: #17a2b8;
  --warning: #ffc107;
  --danger: #dc3545;
  --light: #f8f9fa;
  --dark: #343a40;
  --breakpoint-xs: 0;
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

Is there any way to get that by javascript programmatically?

I want to have this information based on each CSS template programmatically.

I can parse the .css file for that but it is ugly!

enter image description here

HamedFathi
  • 3,667
  • 5
  • 32
  • 72
  • https://stackoverflow.com/questions/36088655/accessing-a-css-custom-property-aka-css-variable-through-javascript – Temani Afif Jan 09 '18 at 19:32
  • https://stackoverflow.com/questions/38002667/change-css-variable-using-jquery – Temani Afif Jan 09 '18 at 19:33
  • these are called CSS variable and you can find what you need in the link above ;) – Temani Afif Jan 09 '18 at 19:33
  • What exactly do you want to do with it? – charlietfl Jan 09 '18 at 19:40
  • @TemaniAfif It's typically better not to mark the question as a duplicate of a second question also closed as a duplicate. Follow the trail to the ultimate target and mark this question as a dupe of *that* one. – TylerH Jan 09 '18 at 20:07
  • 1
    @TylerH yes true, but i always try to get all the questions that ca be possible duplicates (even if they are also duplicates) because i know that we can make question to have many dupes. So if a gold CSS is here he will add all of them ;) but yes i should have choosed the second one – Temani Afif Jan 09 '18 at 20:10

0 Answers0