I've designed my webpage using Tailwind CSS. However, as I have more than 400,000 webpages, adding the same class names everywhere would increase the final size a whole lot. Is there a way to extract the CSS rules from the class names I added in the webpage and put them in a CSS file, so that I can simply include this CSS file in all webpages?
You can see all the CSS used in a webpage by using a browser extension and then copy all of them.
I had used this - https://chrome.google.com/webstore/detail/css-used/cdopjfddjlonogibjahpnmjpoangjfff?hl=en
Related
What I want is, for example, to change the css background color of navigations bar of .navbar-default, which can be done by .navbar-default{background-color:#000;}
But I want is, to see the full css style definitions of .navbar-default class, so I can look and change every element(text-color, hovering colors and every other thing) as I like. Rather than inspecting webpage elements for css codes from browsers, I want to look in a place where the definitions contain.
You can find all in readable format here
If you are using the CDN "version" of Bootstrap, then you won't be able to edit the CSS.
A good way to do what you want is by using your own local copy of the bootstrap.css file. You'll find herein all the definitions, and you can alter them as per your wish.
Conversely, you could also edit the .sass or .less files if you want more control.
edit:
Since the OP is using CDN, follow the following steps and you should be just fine:
Identify the element/ tag that you want to edit: div, input, etc.
Identify the attribute you want to edit: color, height, etc.
most importantly: identify the class or id of the element.
After you've done the above, create a new styles file, for example: styles.css, and write your new custom CSS rules in there as per CSS rules.
Include this file by linking it in your .html file using the link tag
Voila!
You can find and edit it in bootstrap.min.css
This is for new version
https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.css
Just check the header import link and remove .min part if its minimised link
I've been working on site using bootstrap. Rather than calling the unedited bootstrap.css and creating a seperate .css file for customisation I added my css changes directly to the bootstrap.css.
My question is - will this cause problems when it comes to using datatables?
Not necesserily. Depends on which classes are used in datatables. You either search in the source of datatables which classes are used or , what i recommend, make your own css, include it after the bootstrap css and change only what you need. For example with the !important markup.
I have a web page, Page-A, that uses a primary css file. I have other pages, Page-B, that use another primary css file. I'd like to use two classes of the Page-B css file into Page-A, but I do not want to override other classes and functions of Page-A css with this Page-B css file.
Is it possible to import only two classes of a css file instead of all its classes. In other words, is it possible to constrain an #import or link to load only a few classes?
What you could do is mark the classes that will be overriding everything with the !important tag in CSS, which means that it will not be overridden.
I would just input the two classes you want into the Page-A css file, as there is unfortunately no way to just import certain classes.
I would suggest making one master CSS file and input into both pages, that way all of your changes are reflected on both pages.
No. It's not possible.
But: You can still prefix your CSS rules with a class or an ID. It can helps you work with specificity (http://bit.ly/1aODhdu) and with rule importance.
You can also prefix CSS rule which will be applied-only for some nodes like html.one div html.two div so after load second CSS file will be still ignored.
No, it is not possible to import specific classes from a CSS file.
The correct way to do this would be to create a master CSS file, which all your webpages can share.
Delete the classes you need from PageBs css(OPTIONAL), add them to a new CSS file.
Link the new file to both the pages.
This way you will not override any classes and have a CSS file which has all the shared classes both pages need.
There have been some questions regarding this topic before but I am a bit lost and I would appreciate someone to explain this to me in a different way.
Context: I am using twitter bootstrap in my rails app (without Less, not familiar with Less or what it is but that's a separate issue)
I have been teaching myself CSS and when looking at the application.html.erb file in my rails app it calls certain classes such as "nav-bar" and "container-fluid nav-collapse". I am trying to find the css file where these classes are defined (so that i can customize them) but I cannot find it. So far I have tried the bootstrap_and_overrides.css and application.css.scss files but couldnt find the navbar class. Also I have tried these links: Bootstrap CSS Editing
Editing navbar text color in twitter bootstrap but I wasnt able to have any luck.
You should never directly edit bootstrap css files.
For whatever you need to update as you mentioned use bootstrap_and_overrides.css or your custom.css file for overriding original classes and divs.
The best way to find where the classes are in css file is if you are using firefox, click:
Inspect Element and on the right side you will see the name of .css file where this class is saved.
But when you have class name you can just override this class with your rules. Don't forget to include your custom.css file though.
If you still have troubles finding where particular classes are hiding you can use firebug to track what files are loaded like this:
For each file you have the source where you can see the path and find the elements.
For using a site like jsfiddle or cssdesk, how would I pull all the css rules that apply to my element together in one place? My CMS has a pretty large number of CSS files that act on the same elements.
Use Firefox's built-in inspector (not firebug) to inspect the element. In the column that pops up for the inspector, choose "Computed" tab.
Highlight all the styles you want, then right click and choose, Copy Selection.
Go to your jsFiddle or CSSDeck, paste in the properties, and surround it with your rule:
h1 {
... your copied stuff here ...
}
NOTE: you'll need to add semicolons to the end of all the properties.
Not sure if I'm understanding the question properly, but I think you're asking how to apply all the same styles on a fiddle that are applied on your own site. If that's the case, then on jsFiddle, in the left nav, there is an Add Resources option. If your site is public, then you can enter in the direct url to your css file(s) there.
Then any html you enter in the fiddle should get the styles from those css files applied in the result when you run it.
Two answers spring to mind:
The first is simply to upload your CSS files from your laptop to a server somewhere. You could also run a webserver from your laptop if you can open port 80 from your router to your local computer. You could get a static URL to your IP address from a service like No-IP Free.
Use a CSS pre-processor like SASS or LESS when composing your CSS on your computer. This requires a bit of a change to your workflow, but you will find the changes make life as a web developer much easier in the long run. Both SASS and LESS understand vanilla CSS, so you don't have to change your existing files, just the extensions. They also both have the ability to import other SASS or LESS files on your computer, and include them in the output generated CSS. So, using SASS for an example… if your main CSS file is called screen.css, move it to screen.scss. The SASS pre-processor will read through and render the file back to CSS after you make changes. Now, to include another file in your screen.scss file, add #import 'newFile.scss'; and the CSS file SASS generates will include both screen.scss and newFile.scss.Following this design paradigm has the additional benefit of keeping all your CSS in one output file. It is recommended that you keep all your CSS in one file to minimize server requests (see Should I still bother keeping all css in one file? for discussion).