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 URL's 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 it's URL and the proper URL extention.
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.
<ul class="drop-down-menu">
<li>
<a href="#">關於我們</a>
<ul>
<li>
<a href="#">服務據點</a>
</li>
<li>
<a href="#">服務客戶</a>
</li>
<li>
<a href="#">服務地區</a>
</li>
<li>
<a href="#">徵才資訊</a>
</li>
</ul>
</li>
<li>
<a href="#">Magento</a></li>
<li>
<a href="#">服務項目</a>
<ul>
<li>
<a href="#">系統整合</a>
<ul>
<li>
<a href="#">Magento與POS訂單系統整合</a>
</li>
<li>
<a href="#">Magento與CRM客戶管理系統整合</a>
</li>
<li>
<a href="#">Magento與ERP管理系統整合</a>
</li>
<li>
<a href="#">Magento金流串接服務</a>
</li>
</ul>
</li>
<li>
<a href="#">專業網頁設計</a>
<ul>
<li>
<a href="#">響應式網頁設計 (Responsive Web Design)</a>
</li>
<li>
<a href="#">手機網站設計</a>
</li>
<li>
<a href="#">WordPress 網頁設計</a>
</li>
</ul>
</li>
<li>
<a href="#">網路行銷服務</a>
<ul>
<li>
<a href="#">Amazon亞馬遜網路商城</a>
</li>
<li>
<a href="#">社群媒體行銷</a>
</li>
<li>
<a href="#">SEO 搜尋引擎優化</a>
<ul>
<li>
<a href="#">在地SEO</a>
</li>
<li>
<a href="#">SEO 搜尋引擎優化</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#">網站客製開發</a>
</li>
</ul>
</li>
<li>
<a href="#">專案介紹</a>
</li>
<li>
<a href="#">資訊分享</a>
</li>
<li>
<a href="#">聯絡我們</a>
</li>
</ul>
ul {
/* 取消ul預設的內縮及樣式 */
margin: 0;
padding: 0;
list-style: none;
}
ul.drop-down-menu {
border: #ccc 1px solid;
display: inline-block;
font-family: "Open Sans", Arial, sans-serif;
font-size: 13px;
}
ul.drop-down-menu li {
position: relative;
white-space: nowrap;
border-right: #ccc 1px solid;
}
ul.drop-down-menu > li:last-child {
border-right: none;
}
ul.drop-down-menu > li {
float: left;
/* 只有第一層是靠左對齊*/
}
ul.drop-down-menu a {
background-color: #fff;
color: #333;
display: block;
padding: 0 30px;
text-decoration: none;
line-height: 40px;
}
ul.drop-down-menu a:hover {
/* 滑鼠滑入按鈕變色*/
background-color: #ef5c28;
color: #fff;
}
ul.drop-down-menu li:hover > a {
/* 滑鼠移入次選單上層按鈕保持變色*/
background-color: #ef5c28;
color: #fff;
}
ul.drop-down-menu ul {
border: #ccc 1px solid;
position: absolute;
z-index: 99;
left: -1px;
top: 100%;
min-width: 180px;
}
ul.drop-down-menu ul li {
border-bottom: #ccc 1px solid;
}
ul.drop-down-menu ul li:last-child {
border-bottom: none;
}
ul.drop-down-menu ul ul {
/*第三層以後的選單出現位置與第二層不同*/
z-index: 999;
top: 10px;
left: 90%;
}
ul.drop-down-menu ul {
/*隱藏次選單*/
left: 99999px;
opacity: 0;
-webkit-transition: opacity 0.3s;
transition: opacity 0.3s;
}
ul.drop-down-menu li:hover > ul {
/* 滑鼠滑入展開次選單*/
opacity: 1;
-webkit-transition: opacity 0.3s;
transition: opacity 0.3s;
left: -1px;
border-right: 5px;
}
ul.drop-down-menu li:hover > ul ul {
/* 滑鼠滑入之後、次選單之後的選單依舊隱藏*/
left: 99999px;
}
ul.drop-down-menu ul li:hover > ul {
/* 第二層之後的選單展開位置*/
left: 90%;
}
Also see: Tab Triggers