Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Firebug to get a deep copy of CSS in elements

Tags:

css

firebug

I am using Firebug to inspect the elements of a webpage. On the right hand of the page there is a "style" tab that list all the CSS styling for a given tag. These CSS styling are coming from a linked CSS page.

What I am looking to do is somehow copy a set of divs with the CSS hardcoded in the div. This way I can copy and paste the elements and have the exact same styling. Is this possible to do with Firebug or perhaps another tool?

like image 647
Alexis Avatar asked Nov 15 '10 02:11

Alexis


People also ask

How do you copy a CSS element?

Right click on the element with mouse and select Copy Css Selector menu item into buffer, so you can past copied selector to any text editor. Very useful for quickly getting selector for any element for testing frameworks like as Selenium.

How do I copy all CSS from a website?

First, hover over the element you want to copy. Then, right-click on it and choose the option “Inspect”. On the left side is the HTML DOM tree, and on the right side, the CSS styles of the selected element. Having the right element selected on the HTML DOM tree, right-click on it and choose “Copy” > “Copy styles”.


2 Answers

I used IE9 to accomplish this.

  1. Open a page where you want to grab a style in IE9
  2. Press F12 to display Developer Toolbar
  3. In the Developer Toolbar press Find and select "Select element by click"
  4. Then go to "View" > "Source" and select "Element source with style"
like image 105
Dmitry Avatar answered Oct 11 '22 15:10

Dmitry


I don't know about Firebug, but you could build a script to do it.

List the CSS you want to copy (every property you believe is required to make it portable) and then loop through in JS and getComputedStyle(). Then build a ; delimited list of property:value pairs, and assign it to the style attribute if your element and all children.

This doesn't look like an easy task - and you will no doubt run into problems.

like image 1
alex Avatar answered Oct 11 '22 14:10

alex