HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="layout">
<h2>CSS1 Color 关键字</h2>
<ul>
<li>
black(黑)#000000
<div></div>
</li>
<li>
silver(银)#c0c0c0
<div></div>
</li>
<li>
gray(灰)#808080
<div></div>
</li>
<li>
white(白)#ffffff
<div></div>
</li>
<li>
maroon(褐)#800000
<div></div>
</li>
<li>
red(红)#ff0000
<div></div>
</li>
<li>
purple(紫)#800080
<div></div>
</li>
<li>
fuchsia(紫红)#ff00ff
<div></div>
</li>
<li>
green(绿)#008000
<div></div>
</li>
<li>
lime(绿黄)#00ff00
<div></div>
</li>
<li>
olive(橄榄绿)#808000
<div></div>
</li>
<li>
yellow(黄)#ffff00
<div></div>
</li>
<li>
navy(藏青)#000080
<div></div>
</li>
<li>
blue(蓝)#0000ff
<div></div>
</li>
<li>
teal(青)#008080
<div></div>
</li>
<li>
aqua(水绿)#00ffff
<div></div>
</li>
</ul>
<h2>CSS2 Color 关键字</h2>
<ul>
<li>
orange(橙)#ffa500
<div></div>
</li>
</ul>
<h2>CSS3 Color 关键字</h2>
<ul>
<li>
aliceblue(浅灰蓝)#f0f8ff
<div></div>
</li>
<li>
antiquewhite(古董白)#faebd7
<div></div>
</li>
<li>
aquamarine(海蓝)#7fffd4
<div></div>
</li>
<li>
azure(蔚蓝)#f0ffff
<div></div>
</li>
<li>
beige(浅褐)#f5f5dc
<div></div>
</li>
<li>
bisque(橘黄)#ffe4c4
<div></div>
</li>
<li>
blanchedalmond(杏仁白)#ffe4c4
<div></div>
</li>
<li>
blueviolet(蓝紫)#8a2be2
<div></div>
</li>
<li>
brown(褐)#a52a2a
<div></div>
</li>
<li>
burlywood(原木色)#deb887
<div></div>
</li>
<li>
cadetblue(灰蓝)#5f9ea0
<div></div>
</li>
<li>
chartreuse(黄绿)#7fff00
<div></div>
</li>
<li>
chocolate(巧克力色)#d2691e
<div></div>
</li>
<li>
coral(珊瑚红)#ff7f50
<div></div>
</li>
<li>
cornflowerblue(矢车菊蓝)#6495ed
<div></div>
</li>
<li>
cornsilk(玉米穗黄)#fff8dc
<div></div>
</li>
<li>
crimson(深红)#dc143c
<div></div>
</li>
<li>
darkblue(深蓝)#00008b
<div></div>
</li>
<li>
darkcyan(深青)#008b8b
<div></div>
</li>
<li>
darkgoldenrod(暗金)#b8860b
<div></div>
</li>
<li>
darkgray(深灰)#a9a9a9
<div></div>
</li>
<li>
darkgreen(深绿)#006400
<div></div>
</li>
<li>
darkgrey(深灰)#a9a9a9
<div></div>
</li>
<li>
darkkhaki(暗黄褐)#bdb76b
<div></div>
</li>
<li>
darkmagenta(深紫)#8b008b
<div></div>
</li>
<li>
darkolivegreen(深橄榄绿)#556b2f
<div></div>
</li>
<li>
darkorange(深橙)#ff8c00
<div></div>
</li>
<li>
darkorchid(深兰花紫)#9932cc
<div></div>
</li>
<li>
darkred(深红)#8b0000
<div></div>
</li>
<li>
darksalmon(深橙红)#e9967a
<div></div>
</li>
<li>
darkseagreen(深海绿)#8fbc8f
<div></div>
</li>
<li>
darkslateblue(暗灰蓝)#483d8b
<div></div>
</li>
<li>
darkslategray(墨绿)#2f4f4f
<div></div>
</li>
<li>
darkslategrey(墨绿)#2f4f4f
<div></div>
</li>
<li>
darkturquoise(暗宝石绿)#00ced1
<div></div>
</li>
<li>
darkviolet(深紫罗兰)#9400d3
<div></div>
</li>
<li>
deeppink(深粉红)#ff1493
<div></div>
</li>
<li>
deepskyblue(深天蓝)#00bfff
<div></div>
</li>
<li>
dimgray(暗灰)#696969
<div></div>
</li>
<li>
dimgrey(暗灰)#696969
<div></div>
</li>
<li>
dodgerblue(遮板蓝)#1e90ff
<div></div>
</li>
<li>
firebrick(砖红)#b22222
<div></div>
</li>
<li>
floralwhite(花白)#fffaf0
<div></div>
</li>
<li>
forestgreen(丛林绿)#228b22
<div></div>
</li>
<li>
gainsboro(浅灰)#dcdcdc
<div></div>
</li>
<li>
ghostwhite(幽灵白)#f8f8ff
<div></div>
</li>
<li>
gold(金)#ffd700
<div></div>
</li>
<li>
goldenrod(橘黄)#daa520
<div></div>
</li>
<li>
greenyellow(黄绿)#adff2f
<div></div>
</li>
<li>
grey(灰)#808080
<div></div>
</li>
<li>
honeydew(蜜瓜色)#f0fff0
<div></div>
</li>
<li>
hotpink(亮粉)#ff69b4
<div></div>
</li>
<li>
indianred(印第安红)#cd5c5c
<div></div>
</li>
<li>
indigo(靛蓝)#4b0082
<div></div>
</li>
<li>
ivory(象牙白)#fffff0
<div></div>
</li>
<li>
khaki(卡其色)#f0e68c
<div></div>
</li>
<li>
lavender(淡紫)#e6e6fa
<div></div>
</li>
<li>
lavenderblush(淡紫红)#fff0f5
<div></div>
</li>
<li>
lawngreen(草绿)#7cfc00
<div></div>
</li>
<li>
lemonchiffon(粉黄)#fffacd
<div></div>
</li>
<li>
lightblue(淡蓝)#add8e6
<div></div>
</li>
<li>
lightcoral(浅珊瑚色)#f08080
<div></div>
</li>
<li>
lightcyan(淡青)#e0ffff
<div></div>
</li>
<li>
lightgoldenrodyellow(浅金黄)#fafad2
<div></div>
</li>
<li>
lightgray(浅灰)#d3d3d3
<div></div>
</li>
<li>
lightgreen(浅绿)#90ee90
<div></div>
</li>
<li>
lightgrey(浅灰)#d3d3d3
<div></div>
</li>
<li>
lightpink(淡粉)#ffb6c1
<div></div>
</li>
<li>
lightsalmon(浅肉色)#ffa07a
<div></div>
</li>
<li>
lightseagreen(浅海绿)#20b2aa
<div></div>
</li>
<li>
lightskyblue(浅天蓝)#87cefa
<div></div>
</li>
<li>
lightslategray(浅青灰)#778899
<div></div>
</li>
<li>
lightslategrey(浅青灰)#778899
<div></div>
</li>
<li>
lightsteelblue(浅钢蓝)#b0c4de
<div></div>
</li>
<li>
lightyellow(浅黄)#ffffe0
<div></div>
</li>
<li>
limegreen(酸橙绿)#32cd32
<div></div>
</li>
<li>
linen(亚麻色)#faf0e6
<div></div>
</li>
<li>
mediumaquamarine(中绿)#66cdaa
<div></div>
</li>
<li>
mediumblue(中蓝)#0000cd
<div></div>
</li>
<li>
mediumorchid(间兰花紫)#ba55d3
<div></div>
</li>
<li>
mediumpurple(中紫)#9370db
<div></div>
</li>
<li>
mediumseagreen(间海绿)#3cb371
<div></div>
</li>
<li>
mediumslateblue(中暗蓝)#7b68ee
<div></div>
</li>
<li>
mediumspringgreen(中春绿)#00fa9a
<div></div>
</li>
<li>
mediumturquoise(中海湖蓝)#48d1cc
<div></div>
</li>
<li>
mediumvioletred(中紫罗兰)#c71585
<div></div>
</li>
<li>
midnightblue(午夜蓝)#191970
<div></div>
</li>
<li>
mintcream(薄荷乳白)#f5fffa
<div></div>
</li>
<li>
mistyrose(粉玫瑰红)#ffe4e1
<div></div>
</li>
<li>
moccasin(鹿皮色)#ffe4b5
<div></div>
</li>
<li>
navajowhite(纳瓦白)#ffdead
<div></div>
</li>
<li>
oldlace(浅米色)#fdf5e6
<div></div>
</li>
<li>
olivedrab(橄榄褐)#6b8e23
<div></div>
</li>
<li>
orangered(橙红)#ff4500
<div></div>
</li>
<li>
orchid(兰花紫)#da70d6
<div></div>
</li>
<li>
palegoldenrod(灰菊黄)#eee8aa
<div></div>
</li>
<li>
palegreen(苍绿)#98fb98
<div></div>
</li>
<li>
paleturquoise(苍宝石绿)#afeeee
<div></div>
</li>
<li>
palevioletred(苍紫罗兰)#db7093
<div></div>
</li>
<li>
papayawhip(木瓜色)#ffefd5
<div></div>
</li>
<li>
peachpuff(桃色)#ffdab9
<div></div>
</li>
<li>
peru(秘鲁色)#cd853f
<div></div>
</li>
<li>
pink(粉)#ffc0cb
<div></div>
</li>
<li>
plum(李子色)#dda0dd
<div></div>
</li>
<li>
powderblue(粉蓝)#b0e0e6
<div></div>
</li>
<li>
rosybrown(玫瑰粽)#bc8f8f
<div></div>
</li>
<li>
royalblue(宝蓝)#4169e1
<div></div>
</li>
<li>
saddlebrown(马鞍棕)#8b4513
<div></div>
</li>
<li>
salmon(鲑肉色)#fa8072
<div></div>
</li>
<li>
sandybrown(沙褐色)#f4a460
<div></div>
</li>
<li>
seagreen(海绿)#2e8b57
<div></div>
</li>
<li>
seashell(贝壳白)#fff5ee
<div></div>
</li>
<li>
sienna(赭)#a0522d
<div></div>
</li>
<li>
skyblue(天蓝)#87ceeb
<div></div>
</li>
<li>
slateblue(青蓝)#6a5acd
<div></div>
</li>
<li>
slategray(青灰)#708090
<div></div>
</li>
<li>
slategrey(青灰)#708090
<div></div>
</li>
<li>
snow(雪白)#fffafa
<div></div>
</li>
<li>
springgreen(春绿)#00ff7f
<div></div>
</li>
<li>
steelblue(铁青)#4682b4
<div></div>
</li>
<li>
tan(棕褐)#d2b48c
<div></div>
</li>
<li>
thistle(苍紫)#d8bfd8
<div></div>
</li>
<li>
tomato(番茄红)#ff6347
<div></div>
</li>
<li>
turquoise(蓝绿)#40e0d0
<div></div>
</li>
<li>
violet(紫罗兰色)#ee82ee
<div></div>
</li>
<li>
wheat(麦色)#f5deb3
<div></div>
</li>
<li>
whitesmoke(烟白)#f5f5f5
<div></div>
</li>
<li>
yellowgreen(黄绿)#9acd32
<div></div>
</li>
</ul>
<h2>CSS4 Color 关键字</h2>
<ul>
<li>
rebeccapurple(利百加紫)#663399
<div></div>
</li>
</ul>
</div>
.layout {
}
ul {
display: flex;
flex-wrap: wrap;
padding: 0;
}
ul li {
width: 30%;
list-style-type: none;
border: 1px solid #e3e3e3;
margin: 0 1% 20px;
color: #666;
text-align: center;
font-size: 14px;
line-height: 20px;
}
li div {
height: 50px;
}
(function(){
var list = document.querySelectorAll('li')
var index = 0
while (index < list.length ) {
let curr = list[index]
console.log(curr)
let color = curr.innerText.split('#')[1]
let child = curr.querySelector('div')
child.style.backgroundColor = `#${color}`
index++
}
})()
Also see: Tab Triggers