Html 从 Google Chrome 中的 Inspect Element 复制代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12576247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copying Code from Inspect Element in Google Chrome
提问by mars
I'm currently developing a website in HTML and I want to copy some of the code from other websites. However when I go into the inspect element feature and try to copy just part of the code it ends up copying the whole script. Is there any way I can get just part of the code from inspect element without having to copy the whole thing and cut out the bits that I don't want in dreamweaver?
我目前正在开发一个 HTML 网站,我想从其他网站复制一些代码。但是,当我进入检查元素功能并尝试仅复制部分代码时,它最终会复制整个脚本。有什么方法可以让我从inspect 元素中获取部分代码,而不必复制整个内容并删除我在dreamweaver 中不想要的部分?
回答by User
Right click on the particular element (e.g. div
, table
, td
) and select the copy as html.
右键单击特定元素(例如div
, table
, td
)并选择副本为 html。
回答by Calsal
In earlier versions of Chrome we could simply select and copy an element (with Ctrl+C or Cmd+C) and then paste it inside an element by selecting it and then paste (with Ctrl+V or Cmd+V). It's not possible in the latest versions though (I'm running Chrome 58.0.3029.110) and it has set me up many times since then.
在早期版本的 Chrome 中,我们可以简单地选择并复制一个元素(使用 Ctrl+C 或 Cmd+C),然后通过选择它然后粘贴(使用 Ctrl+V 或 Cmd+V)将其粘贴到元素中。不过,在最新版本中这是不可能的(我运行的是 Chrome 58.0.3029.110),从那时起它已经设置了我很多次。
Instead of using the commands for copy and paste, we now have to right click the element -> Copy -> Copy Element and then right click the element that we want to append the copied element to -> Copy -> Paste Element.
而不是使用复制和粘贴命令,我们现在必须右键单击元素 -> 复制 -> 复制元素,然后右键单击我们想要将复制的元素附加到的元素 -> 复制 -> 粘贴元素。
I don't understand why the short commands are deactivated but at least it's still possible to do it in a more inconvenient way.
我不明白为什么短命令被停用,但至少仍然可以以更不方便的方式进行。
回答by Joshua Dance
Click on the line or element you want to copy. Copy to clipboard. Paste.
单击要复制的行或元素。复制到剪贴板。粘贴。
The only tricky thing is if you click on a line, you get everything that line includes if it was folded. For example if you click on a div, and copy, you get everything that the div includes.
唯一棘手的事情是,如果您单击一条线,您将获得该线包括折叠的所有内容。例如,如果您单击一个 div 并复制,您将获得该 div 包含的所有内容。
You can also get only what you want by Right Clicking, and select 'Edit as HTML'. This will make that section essentially text, with none of the folding activated. You can then select, copy and paste the relevant bits.
您也可以通过右键单击仅获取您想要的内容,然后选择“编辑为 HTML”。这将使该部分本质上是文本,没有激活任何折叠。然后您可以选择、复制和粘贴相关位。
回答by Abdullah Khan
You can copy by inspect element and target the div you want to copy. Just press ctrl+c and then your div will be copy and paste in your code it will run easily.
您可以通过检查元素复制并定位要复制的 div。只需按 ctrl+c,然后您的 div 将被复制并粘贴到您的代码中,它将轻松运行。
回答by Sheson Jose C
you dont have to do that in the Google chrome. Use the Internet explorer it offers the option to copy the css associated and after you copy and paste select the style and put that into another file .css to call into that html which you have created. Hope this will solve you problem than anything else:)
你不必在谷歌浏览器中这样做。使用 Internet Explorer,它提供了复制关联 css 的选项,在复制和粘贴后选择样式并将其放入另一个文件 .css 中以调用您创建的 html。希望这能解决您的问题,而不是其他任何问题:)